How to run a cron job which runs every 4 hrs starting at 4:30 pm and shouldnt run between 2 am and 6am - cron

I have tried creating a cron expression starting at 4 pm running every 4 hrs but not sure how to start at 4:30.
Below is the expression:0 0 16/4,20,0,8,12? * * *

Related

Need a cron expression

I am trying to get a cron expression through cron convertors online but it won't be able to do the same.
Some please help. I need a cron expression which should run every 3 hours starting at 00:10.
00:10
03:10
06:10
...
Also I need a cron expression that runs every 30 mins starting from 00:00.
00:00
00:30
01:00
...
something like this^
I tried
10/3 * * * *
and
*/30 * * * *
I need a cron expression which should run every 3 hours starting at
00:10
Simply with
10 0/3 * * * your_command
This way, the cron will run the specified command at 10 minutes past midnight (10 0) and then every 3 hours thereafter (0/3)
Also I need a cron expression that runs every 30 mins starting from
00:00
Then this might do the work
0,30 0-23/1 * * * /path/to/command
So it will run at 00:00 and 00:30 every day (0,30), every hour (0-23/1), and regardless of the day of the month, month, or day of the week (*)

Cron pattern for multiple time with *AND*

I want to create a cron pattern for the expression Every day at 7 PM, 8:30 PM and 9:45 PM.
Is it possible to create one cron pattern for it or I will have to write 3 separate ones?
With cron alone you would have to create 3 separate cron jobs. However, here's a possible workaround: you can create a single cron entry for 7 PM, such as:
0 19 * * * /folder/script
And then create a script that "sleeps" the time you need before calling the other commands at 8:30 PM and 9:45 PM, such as:
#!/bin/bash
nohup my_command_here &
#sleep until 8:30 PM - 90 minutes or 5400 seconds
sleep 5400
nohup my_command_2_here &
#sleep until 9:45 PM - 75 minutes or 4500 seconds
sleep 4500
nohup my_command_3_here &
exit

How to set Cron Job for 11 PM to 11:59 PM

I want to send emails automatically between 9 PM to 9 AM after every 2 minutes.
I have set the cron job as below
*/2 21-23, 0-9 * * *
Its running perfectly But I am not able to set it to include the time between 11 PM-11:59 PM.

Scheduling scripts with variable frequency

I want to run a python script on a ubuntu 14.04 server with following frequency:
Monday to Friday:
From 0800 hrs to 1600 hrs: Run once every hour
From 1600 hrs to 2300 hrs: Run once every 30 minutes
Saturday and Sunday:
From 0800 hrs to 2300 hrs: Run once every two hours
At other times, don't run
Is this possible with cron? If not, can anybody suggest some alternative?
As suggested in the comments, adding these cron entries will do:
(Lines starting with # are comments)
# monday to friday, 8 am to 4 pm, once every hour
0 8-16 * * 1-5 <command>
# monday to friday, 4 pm to 10 pm, twice every hour
0,30 17-22 * * 1-5 <command>
# saturday to sunday, 8 am to 11 pm, once every hour
0 8-23 * * 0,6 <command>

Running a cron job every 2:30 on every day?

If I creating cronjob to running for every 2:30 the command will run? (It mean, my cron will running after 90 minutes for every hours.)
the command like: 30 */2 * * * /command/xxx => that's right?
Please help?
Your cron expression 30 */2 * * * will run the command every 2 hours at 30 mins past the hour i.e.00:30, 02:30, 04:30, 06:30 and so on.
If you want to run your command at intervals of two and a half hours i.e. 00:00, 02:30, 05:00, 07:30 and so on, you need to set up two crons:
0 0-20/5 * * * runs at 0 mins past the hour, every 5 hours between 00:00 and 20:00 inclusive i.e. 00:00, 05:00, 10:00, 15:00 and 20:00
30 2-22/5 * * * runs at 30 mins past the hour, every 5 hours between 02:00 and 22:00 inclusive i.e. 02:30, 07:30, 12:30, 17:30 and 22:30
On the other hand, if you want to run your command only once every day at 02:30 use 30 2 * * *.
sudo crontab -e
and then add this:
30 2 * * * /enter/your/command

Resources