35

I have 2 cron jobs, i want one of them to run every odd minute (1,3,5,7,9,11....57,59) and i want the other one to run every even minute (0,2,4,6,8,10,12...58)

how can i do it in an easy way? (no scripting - just cron job rules)

62
*/2 * * * * date >>/tmp/even
1-59/2 * * * * date >>/tmp/odd
  • whoops! i bet you supplied the correct syntax for the "1-59/2" part... can i ask why when i enter this in cpanel it doesnt work? It says "Cron field not formatted correctly..." – wabbajay Jan 7 '11 at 21:43
  • I don't use cpanel, but I'm going to go out on a limb and suggest that the filter they have placed between you and the actual crontab doesn't see it as valid. It really is though, I typed that exactly into my crontab on a CentOS5 server and got the even minutes in in /tmp/even and odd minutes in /tmp/odd. Sorry cpanel's filtering it... – jj33 Jan 7 '11 at 21:46
  • thats what i suspected too... i ll set it manually... thank you for your help jj33 :) – wabbajay Jan 7 '11 at 21:53
  • 5
    FYI, for the 1-59/2 syntax. if you want an explaination see stackoverflow.com/a/122499/658023 – General Redneck Jun 12 '15 at 21:19
4
*/2 * * * * /path/to/foo
*/2 * * * * sleep 60; /path/to/bar

Is that that sleep 60 too much like a script?

  • yes its more like a script and for sure it is not "just cron job rules". thank you for your time anyway ;) – wabbajay Jan 7 '11 at 21:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.