How to run cron jobs on even/odd days, minutes etc..

Ever wondered how to start a cron job on even/odd minute/day/hour ?

Here are some examples:

Example1: You want to run job on even/odd minute:

0-59/2 * * * * /path/to/evenjob.sh
1-59/2 * * * * /path/to/oddjob.sh

Example2: You want to run job in 10th minutie of every even/odd hour:

10 0-23/2 * * * /path/to/evenjob.sh
10 1-23/2 * * * /path/to/oddjob.sh

Example3: You want to run job at 5pm every even/odd date

0 17 2-31/2 * * /path/to/evenjob.sh
0 17 1-31/2 * * /path/to/oddjob.sh

If you dont clearly remember the positions of the minutes/hours/days you can find them in this man page:

man 5 crontab

here is a snippet from it:


field allowed values
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

No comments:

Post a Comment

Comment