by

How to run a cronjob every odd or even minute

I’ve tested this for Vixie Cron and Cronie.

There is an “extensions” section on the crontab(5) man page which says – Ranges can include “steps”, so “1-9/2” is the same as “1,3,5,7,9”.

*/2 * * * * date >>/tmp/even
1-59/2 * * * * date >>/tmp/odd

If you require more portability across different versions, you may want to stick to the much simpler list:

1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59

But it might be easier to write a shell script which is called every minute and wrap your command in it, which will immediately exit if it is not called in an odd minute.

Share your views

Comment