Reputation: 4045
I have read the answers and I am not able to get an explanation whether this expression will work:
*/5 930-1530 * * 1-5 <command>
I am trying to run a script every 5 minutes between 9:15AM to 15:30PM only on weekdays
New to cron
and ubuntu
Thanks in advance.
Upvotes: 4
Views: 7345
Reputation: 81
9:30 to 15:30
30/5 9-15 * * 1-5
You also can use this tool for generate right configuration line: https://crontab.guru
If you need 9:15 to 15:30, then use:
15/5 9-16 * * 1-5
But it start from 9:15 to 16:15, now inside script you need check current time and stop the script execution, if time bigger than 15:30. I know its ugly way, because from 15:30 to 16:15 u will have 9 waste calls your script.
upd. Another variant:
15/5 9-15 * * 1-5
20-30/5 15 * * 1-5
Here we start from 9:15 - 15:15, last call at 15:15, so next line start from 15:20 - 15:30. I think it's a better way.
Upvotes: 1
Reputation: 427
30-59/5 9 * * 1-5 <command>
0-30/5 15 * * 1-5 <command>
*/5 10-14 * * 1-5 <command>
Try it (like in your comments) with three separate tabs.
Upvotes: 5