tkokoszka tkokoszka - 1 year ago 75
Linux Question

How to instruct cron to execute a job every second week?

I would like to run a job through cron that will be executed every second Tuesday at given time of day. For every Tuesday is easy:

0 6 * * Tue

But how to make it on "every second Tuesday" (or if you prefer - every second week)?
I would not like to implement any logic in the script it self, but keep the definition only in cron.

Answer Source

How about this, it does keep it in the crontab even if it isn't exactly defined in the first five fields:

0 6 * * Tue expr `date +\%W` \% 2 > /dev/null || /scripts/
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download