Differences
This shows you the differences between two versions of the page.
— |
general:cron_tricks [2019/05/24 11:06] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | =====Cron Tricks===== | ||
+ | ====Schedule a job on the 2nd Tuesday of the month==== | ||
+ | |||
+ | Cron doesn't have the flexibilty to allow you to schedule a script on, for example, the second Tuesday of every month. However this can be achieved using some date checking in your crontab entry, e.g. | ||
+ | |||
+ | 00 09 * * 2 [ $(date +\%d) -gt 7 ]&& [ $(date +\%d) -lt 15 ] && /run/your/script | ||
+ | |||
+ | The second Tuesday of the month will fall in a date range of the 8th to the 14th. The command will run at 9:00 every Tuesday but then check whether the day is in the range 8th - 14th before executing the script | ||
+ | |||
+ |