3 ms·
Writing a fail-safe cron is an incredibly hard job as crons are infamous for failing rather silently. The cron script writer must take a very pessimist approach
by vijayaggarwal 12y ago
Writing a fail-safe cron is an incredibly hard job as crons are infamous for failing rather silently. The cron script writer must take a very pessimist approach and handle every possibility of error. Even then, some scenarios are easy to miss. Following are some cases I have come across often:
1. crash - any runtime error that causes your script to stop execution abruptly.
2. un-handled, non-crashing error - db connection failure, remote api failure, file not found, etc. The script may continue execution, the results may not be logically correct.
3. concurrent execution - What if an instance of cron is not over by the time the next instance should start? crontab will simply start the next instance.
4. internet connection error - even the notification mechanism will fail if it depends on an active internet connection.
Your service is a very valuable one, and a challenging one too I believe. You can do a lot many things in cron monitoring and reporting.