I need a cron job. It should run be every day on Monday till Thursday, starting at 16:30, executing every 5 minutes till 03:30 AM next day. On Friday it will start at 16:30 executing every 5 minutes till Monday 03:30 AM. Thank you very much!
0
votes
1 Answers
1
votes
Based on your comment you need two records like this:
This cover:
Need to run every weekday from Monday till Thursday, starting at 23:05, exporting every 5 minutes till 11:00 AM next day
5,10,15,20,25,30,35,40,45,50,55 23 * * 1-4 command
*/5 0-11 * * 2-5 command
This cover:
On Friday start to run at 23:05 until Monday 11:00 AM
5,10,15,20,25,30,35,40,45,50,55 23 * * 5 command
*/5 * * * 6,7 command
*/5 0-11 * * 1 command
And when we optimize the cron records we will get something like:
*/5 0-11 * * 1-5 command
5,10,15,20,25,30,35,40,45,50,55 23 * * 1-5 command
*/5 * * * 6,7 command
EDIT1: As per question change you need:
Monday till Thursday, starting at 16:30, executing every 5 minutes till 03:30 AM next day
30,35,40,45,50,55 16 * * 1,2,3,4 command
*/5 17,18,19,20,21,22,23 * * 1,2,3,4,5 command
*/5 0,1,2 * * 2,3,4,5 command
0,5,10,15,20,25 3 * * 2,3,4,5 command
On Friday it will start at 16:30 executing every 5 minutes till Monday 03:30 AM
30,35,40,45,50,55 16 * * 5 command
*/5 * * * 6,7 command
*/5 0,1,2 * * 1 command
0,5,10,15,20,25 3 * * 1 command
And to "optimize" the cron records
30,35,40,45,50,55 16 * * 1-5 command
*/5 0,1,2 * * 1,2,3,4,5 command
0,5,10,15,20,25 3 * * 1,2,3,4,5 command
*/5 17,18,19,20,21,22,23 * * 1,2,3,4,5 command
*/5 * * * 6,7 command