Lately at work I've been hacking out SQL scripts to update billing records in a mysql table before the billing run on the 1st of the month at 0000h. So I want to run them on the last day of the month, but vixie cron doesn't have a -1 value for the day of month field meaning "the last day". I could wrapperize the SQL in a perl script using Date::Simple, but I wanted to keep it simpler, so I found I could do:
Since @RunNow is only true on the last day of the month, this script only ever does anything on the last day. And my /etc/crontab can look like:
Also, I start my where clauses now with a 1, as in developing scripts it's useful to be able to comment out a line with a '--' at the front of the line without having to alter any other lines. If I wanted to comment out the first where condition, I'd have to alter the subsequent line. Not so if my first where condition is always true. It's a pity that I can't do the same with my select columns.