Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run every 2nd and 4th Saturday of the month

Tags:

cron

crontab

What's the cron (linux) syntax to have a job run on the 2nd and 4th Saturday of the month?

like image 945
Neil Avatar asked Jul 27 '12 07:07

Neil


1 Answers

Expanding on @paxdiablo's reply, why not just put the addition into the crontab, instead of the script?

#m h dom       mon dow command
0  1 8-14,22-28 *   *   [ `date +\%u` = 6 ] && /path/to/myscript

Note the backslash before %u, which is not needed when you try this on the command line, but it is needed in a crontab entry to ensure the shell gets to see the whole command.

Doing it this way puts all the logic for selecting the proper day in the place your colleagues first look at, and you can run the script manually on another day if the need arises.

like image 133
BertD Avatar answered Oct 21 '22 19:10

BertD