Run cron every 5 minutes in specific time span - cron

I would like to run a cron job every 5 minutes in between these time span:
Tuesday: 8pm - 10pm
Wednesday: 8pm - 10pm
Friday: 8.30pm - 10.30pm
Saturday: 3.30pm - 5.30pm and 6.30pm - 8.30pm
Sunday: 3.30pm - 7.30pm
I guess I need more than one line to realize it.
My current crontab looks like this:
COMMAND=curl -u user:password http://localhost/webapp/cache/build/openligadb >> /var/log/cron.log
# Tuesday + Wednesday 8pm - 10pm
# m h dom mon dow command
*/5 20-22 * * 2,3 $COMMAND
# Friday 8.30pm - 10.30pm
# m h dom mon dow command
*/5+30 20-22 * * 5 $COMMAND
# Saturday 3.30pm - 5.30pm and 6.30pm - 8.30pm
# m h dom mon dow command
*/5+30 15-17,18-20 * * 6 $COMMAND
# Sunday 3.30pm - 8.30pm
# m h dom mon dow command
*/5+30 15-20 * * 0 $COMMAND
I don't know how to test/debug cron to look if it's correct what I've written.
I guss currently it would run every 5 minutes as follows:
Tuesday 8pm - 10pm
Wednesday 8pm - 10pm
Friday 8.30pm - 10pm (should be 10.30pm)
Saturday 3.30pm - 5pm (should be 5.30pm) and 6.30pm - 8pm (should be 8.30pm)
Sunday 3.30pm - 8pm (should be 8.30pm)

There's nothing wrong with explicitly listing the times you need if there's no appropriate shortcut:
# Tuesday + Wednesday 8pm - 10pm
*/5 20-22 * * 2,3 $COMMAND
# Friday 8.30pm - 10.30pm
30,35,40,45,50,55 20 * * 5 $COMMAND
*/5 21 * * 5 $COMMAND
0,5,10,15,20,25,30 22 * * 5 $COMMAND
# Saturday 3.30pm - 5.30pm and 6.30pm - 8.30pm
30,35,40,45,50,55 15,18 * * 6 $COMMAND
*/5 16,19 * * 6 $COMMAND
0,5,10,15,20,25,30 17,20 * * 6 $COMMAND
# Sunday 3.30pm - 8.30pm
30,35,40,45,50,55 15 * * 0 $COMMAND
*/5 16-19 * * 0 $COMMAND
0,5,10,15,20,25,30 20 * * 0 $COMMAND

Related

CRON - Run from to on given weekdays only

How do you construct a CRON expression that execute Tuesday to Friday at the times:
03:00 / 03:15 / 03:30 / 03:45 / 4:00 / 4:15?
0 0 3 * * 2-5 <= this just run one time at 3 on Tuesday to Friday
Peter

CRON Expression

Hi Anyone have idea on the CRON EXpression which Fires every 30 minutes starting at 7:00 AM and ending at 7:00 PM, AND fire every 1 hour starting at 7:00 PM and ending at 6:00 AM in the next day, every day
You can make it with 2 tasks of cron:
30 7-19 * * *
60 19-6 * * *

How to set a cron job to run at a exact date and time frame?

How can I set a cron to run every 30 mins between 8 am and 5 pm during the weekedays , here is my code but seems it not working
*/30 8-16 * * 1,2,3,4,5 cd /root/Desktop; ./script.sh
please help me to solve this
Try this ==>
For Weekday
*/30 08-17 * * 1-5 /path_of_file
For Weekend // Saturday, sunday
*/30 08-17 * * 0,6 /path_of_file
*/30 for every half hour
08-17 for 8 AM to 5 PM
1-5 for Monday to friday
0,6 For Sunday and Saturday

How to run a cron job on every Monday, Wednesday and Friday?

How can one run a cron job for every Monday, Wednesday and Friday at 7:00 pm?
Here's my example crontab I always use as a template:
# Use the hash sign to prefix a comment
# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 7) (Sunday=0 or 7)
# | | | | |
# * * * * * command to be executed
#--------------------------------------------------------------------------
To run my cron job every Monday, Wednesday and Friday at 7:00PM, the result will be:
0 19 * * 1,3,5 nohup /home/lathonez/script.sh > /tmp/script.log 2>&1
source
Use crontab to add job
crontab -e
And job should be in this format:
00 19 * * 1,3,5 /home/user/somejob.sh
The rule would be:
0 19 * * 1,3,5
I suggest that you use http://corntab.com for having a very convenient GUI to create your rules in the future :)
This is how I configure it on my server:
0 19 * * 1,3,5 root bash /home/divo/data/support_files/support_files_inc_backup.sh
The above command will run my script at 19:00 on Monday, Wednesday, and Friday.
NB: For cron entries for day of the week (dow)
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday
Use this command to add job
crontab -e
In this format:
0 19 * * 1,3,5 /path to your file/file.php
Use crontab to add job
0 0 9 ? * MON,WED,FRI *
The above expression will run the job at 9 am on every mon, wed and friday.
You can validate this in : http://www.cronmaker.com/
Have you tried the following expression ..?
0 19 * * 1,3,5

Cron Expression to execute cron triggers for 12 hours of a day?

I need a cron-expression (0 0/60 * * * ?) to fire application every 12 hours (twice a day).
Use e.g. 0 0 3,15 * * ? That'll run a job at 3am and 3pm. That's twice a day, with 12 hours between.
You could use 0 0 0/12 * * ? which means every 12 hours. Here's some examples.
Some examples that fit your criteria:
30 */12 * * *
runs at 00:30:00 and 12:30:00 each day
0 3-15/12 * * *
runs at 03:00:00 and 15:00:00 each day
23 4,16 * * *
runs at 04:23:00 and 16:23:00 each day

Resources