Text Link Ads

Friday, April 20, 2007

Run on last sunday

If you want a job to run on the last sunday of every month, you can use the following syntax from within cron:

18 * * * 0 [`date "+%d"` -gt 24] && /path/to/script

i.e. on sundays at 18:00 check if the day of the month is greater than 24 - if so run the job (if 23 is
specified the job will run on the last 2 sundays of the month)

NOTE: There back-ticks around the date command, not single quotes.

No comments: