------------------------------------------------------------------------------- Crontab recipe Hints ------------------------------------------------------------------------------- Who to mail Add MAILTO="user@email.domain" to have crontab mail to your specific address ------------------------------------------------------------------------------- Run first Saturday of Month This is not simple due to some wierd mechnices of day of week handling. This works.. 0 0 1-7 * * [ `date +%u` -eq 6 ] && CMD OR use 0 0 * * 6 [ `date +%d` -le 7 ] && CMD The day checks in the above is needed dur to a problem with crons For example 0 0 1-7 6 CMD will acutally run the command on days 1 to 7 AND even saturday!!! It is not just the first saturday of the month. ------------------------------------------------------------------------------- Run on the LAST saturday of the month A 'decent into madness' http://arstechnica.com/civis/viewtopic.php?f=16&t=34360 First attempts all fail... # july would run twice in 2010 1 0 24-31 * 6 /some/script.sh # april would not run at all in 2010 1 0 25-31 * 6 /some/script.sh But this works.. 1 0 * * 6 [ `date +%d` -eq `echo \`cal | awk '{print $7}'\` | awk '{print $NF}'` ] && /some/script.sh NOTE: echo `cal | awk '{print $7}'` gets the day of saturdays for this month, all onto one line Alternative for getting day of the last saturday cal | awk '{print $7}' | grep -E '[0-9]' | tail -n 1 Better recipe for last saturday... [ `date +%d` -eq `cal | awk '$7!=""{l=$7} END {print l}'` ] && CMD Alternative using GNU date (depends on version) to see if next saturday (in 7 days) is at start of mont 0 0 * * 6 [ `date +%d -d '7 days'` -le '7' ] && CMD or compare the month of next saturday... 1 0 * * 6 [ `date +$m` -eq `date +%m -d "next Saturday"` ] && CMD WARNING: some versions of "cal" starts on mondays, rather than sundays use "cal -s" on those systems. -------------------------------------------------------------------------------