Crontab execute every 15 minutes for two days

Smith Dwayne

After reading crontab manual I used the following command to execute my process for every 15 minutes from 18:00 to 23:00 of a day.

MIN      Minute field    0 to 59
HOUR     Hour field      0 to 23
DOM      Day of Month    1-31
MON      Month field     1-12
DOW      Day Of Week     0-6
CMD      Command         Any command to be executed.

My command,

*/15 18-23 * * * myexec

I want to run my process from the time 18:00 of the day to early morning 01:30 of next day. I want to run this each and every day. How do I do this?

Second Question, If I run this the above process only for weekdays, Is my following command is right?

*/15 18-23 * * 1-5 myexec
Romeo Ninov

You will need three cron records to run it till 1:30:

*/15 18-23 * * * myexec
*/15 0 * * * myexec
0,15 1 * * * myexec

The first two lines can be combines like this:

*/15 0,18,19,20,21,22,23 * * * myexec

If you need to run it only during weekdays think about those runs from midnight. If you want to follow the cycle you will need to run one of them in Saturday. And the command will be:

*/15 18-23 * * 1-5 myexec
*/15 0 * * 2-6 myexec
0,15 1 * * 2-6 myexec

NB! If you want to run it every 30 minutes (as per headline) you need to change your cron records on this way

*/30 18-23 * * 1-5 myexec
*/30 0 * * 2-6 myexec
0 1 * * 2-6 myexec

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related