Cron – How to make cron run every other Sunday on the OTHER Sunday

crondate

I have a cron job that runs at 0 0 * * 0/2 — i.e. every other Sunday. It just ran now, for instance. However, I want it to run on the other Sundays — next Sunday, rather than this one. Another way of putting it: I presume it's running on even-numbered Sundays of the year, but I want it to run on odd-numbered Sundays.

I don't see anything in "man 5 crontab" that would help me with this so I presume I need to drop back to running the cronjob at 0 0 * * 0 and then do something in the command I run to check which Sunday it is. Can anyone help me with some suitable command line trickery for this?

ETA: have realised that my 0/2 doesn't do what I originally thought (every second Sunday) at all. It runs every Sunday, as long as that day of the week is divisible by two, which of course it is. D'oh. Anyway, the fundamental requirement remains: run a command on odd-numbered Sundays.

Best Answer

I won't pretend to have attempted this particular task myself, but this Stack Overflow question has some answers that show potential command line trickery: https://stackoverflow.com/questions/350047/how-to-instruct-cron-to-execute-a-job-every-second-week

Related Topic