All good advice, though for emailing cronic can help stop your mailbox filling with noise.
Myself, I use runit for the task (with an empty ‘down’ file in the service directory to stop it running at boot) and set up cron to kick it off with calls to ‘sv once …’. This tends to spare me much of the pains cron has to offer. With this you get the locking and logging for free, plus it makes it easy to strap into your monitoring system to test for stalled tasks too.
A good cron job is a lot like a good interrupt handler. It should do very little, and be very careful about doing it. Instead it should initiate a task that does the work. My cron jobs are all simple shell scripts that check for a lock file, set up file redirection and logging, etc. then go to work.
All good advice, though for emailing cronic can help stop your mailbox filling with noise.
Myself, I use runit for the task (with an empty ‘down’ file in the service directory to stop it running at boot) and set up cron to kick it off with calls to ‘sv once …’. This tends to spare me much of the pains cron has to offer. With this you get the locking and logging for free, plus it makes it easy to strap into your monitoring system to test for stalled tasks too.
A good cron job is a lot like a good interrupt handler. It should do very little, and be very careful about doing it. Instead it should initiate a task that does the work. My cron jobs are all simple shell scripts that check for a lock file, set up file redirection and logging, etc. then go to work.