Let's talk about Cron Jobs

Let's talk about Cron Jobs

WHAT IS A Cron Job?

One of the golden rules In Engineering is DRY - Do not repeat yourself, hence we have classes in programming languages for reuse and so you don’t begin to sound like a broken record.

Some tasks can be really repetitive and can become a chore. The best way to automate the processes is with cron jobs. You can automate tasks on your Virtual machines and Unix Operating System.

Paul Reiber says
 Cron-based activation is awesome for some needs and horrible for others.
Letting work queue up to be handled periodically by cron introduces resource usage imbalances into systems that would otherwise be much more docile.

Cron's best used to initiate things that should, but don't necessarily have to, be done every so often. Using it to implement a "periodic work-queue handler" isn't a great idea. Generally, it's best to try to "keep the queue empty" - not let work-to-be-done queue up. Cron jobs that run once a minute are preferable for queue handling over ones that run once a day.

How smart is your cron jobs code? Does it know if it's the only copy of itself that's running right now? Consider: what if the job took more than a day to complete? Cron will run another job when told to - right beside the one that's still running from yesterday. Your cron job code can be smart, and exit if there's another copy of itself already running. But... does it, today? You'd be amazed how many things can get screwed up by accident when this happens.

...To be continued