Benjamin Schieder

[SOLUTIONS] RUN CRONJOB EVERY OTHER SATURDAY

2010 February 15

We just had this problem and no "obvious" solution:
How to run a cronjob every other Saturday?

The first step is easy, run a cronjob every Saturday:

0 0 * * 6 /usr/local/bin/job.bash


Then we thought about "guessing" when the first and third Saturday would be:
0 0 8-14,15-22 * 6 /usr/local/bin/job.bash


This works "mostly", but will fail about twice a year. So in the end we run the script every Saturday and add this snippet:
if [ -e /etc/job/runme ] ; then
rm -f /etc/job/runme
else
touch /etc/job/runme
exit -1
fi
...


This will run your cronjob once every other Saturday.


EOF

Category: blog

Tags: Solutions cronjob