A lot can go wrong when you’re using Cron scheduler. If you’ve been running Cron jobs for years, then you know how frustrating and finnicky the system can be.
If your Cron is not running correctly and you plan on scaling, continue reading this guide. We will explore the drawbacks of using Cron and add some suggestions on how to overcome them.
1. Resource wastage
One of the biggest problems with the Cron scheduler is that it works best when run on its own machine.
Let’s say you have a need to run a Cron every 15 minutes. Most of the time, your machine is sitting idle. Or maybe you only need to run one Cron daily.
That’s a lot of money wasted while idling.
2. Failure Handling
An even more significant concern is handling failure.
The task you’re running might fail for a million reasons. It could run into an ephemeral bug, run out of resources, or encounter a million other problems causing it to fail.
To address this, you could wrap your task into another task that checks and restarts it if it fails. However, at this point, you need to worry about your parent task having a bug or crashing.
It’s an infinite loop.
3. Startup Delay
Traditional Unix cron jobs are pretty versatile. What isn't versatile though is working around the inherent limitations of the Cron scheduler.
You can run a more complex Cron every minute system that dynamically starts and stops your machine when it isn’t used so you can avoid resource wastage.
The problem comes when startup delays occur. If you’re using AWS, you could encounter delays if AWS takes longer than usual to allocate a machine. Or perhaps, you might experience network latencies.
These issues can cause startup delays which then cause your Cron job to run at 6:02 when it’s supposed to be scheduled at 6:00. Depending on your setup, this two-minute delay can cause all sorts of problems for your operations.
Cron is easy to manage when you have one or two tasks to run. Scaling, however, can be very challenging with Cron. Many teams use a schedule that fires off a Cron expression every five minutes, but who wants to wait for that?
You can run into all sorts of problems and might even need dedicated staff just to run the Cron Jobs on time, restart any that failed, etc.
To deal with this, many in the industry are switching to workload automation software to replace outdated Cron and batch schedulers.
These are automation platforms dedicated to scheduling your workloads and timed jobs. They don’t have the same drawbacks as Cron, and they have features that Cron doesn’t. Among other things, a Workload Automation platform can help you with:
- ACH processing by integrating seamlessly with connectors for Fiserv, Symitar, Corelation, etc.
- Event-driven file movement
- Data backup and disaster recovery workflows
Below are some strategies you can employ to address the common drawbacks of Cron:
1. Trigger on file change
Let’s say you have a Cron job that’s set to run each time a new file is added or removed from a folder.
To do this, you can run a script that constantly checks the folder every 1 minute. This isn’t ideal and becomes hellishly impossible when you have 1000's of scheduled jobs.
With workload automation software, this is very easy to pull off.
Just select your files/folders and what commands you need to run and let the platform handle the rest. This makes your developers’ lives so much easier since they can avoid tinkering to get complicated Cron jobs to run.
2. Resource wastage
With ordinary Cron, you’d have to deal with wasted computing resources since your software is often idle.
The good news is, you don’t have to deal with this issue when you’re using workload automation software.
You can configure the software to run your commands on time without letting your system sit idle for most of the time. The best part is, you don’t need to mess around with the 1000-line crontab. Just set up your configuration with an easy-to-use GUI, and you’re good to go.
3. Failure handling
With ordinary Cron, your tasks may fail. It may time out, crash, or run out of resources, among other things.
That’s a big problem, of course, because then you need to write a hack around it by encapsulating your script into a parent script that checks if the child script failed. (This can be a massive headache!)
You can forget about all this when you’re using workload automation software. You can just set up your tasks and decide how to handle the failure. You could configure it, so it does nothing, restart if it fails up to 5 times, or keep trying until a particular type, etc.
At the end of the day, you have the choice to go with a system that runs Cron every 15 minutes, with all its frustrating and potentially costly drawbacks, or let automation do all of this for you.
Using workload automation software makes failure handling so much easier for your engineers and increases their productivity.
3. Startup delay
Cron isn’t smart enough to handle startup delays. However, advanced automation software is.
If you schedule a job to run at 6:00 AM, you can rest assured that it will run at some time very close to 6:00 AM. While the software isn’t perfect, it can significantly reduce overall startup delay to give you a better experience.
If you are sick and tired of dealing with Cron jobs that aren’t running properly and you’re thinking of switching to workload automation software, consider the OpCon automation platform.
It’s a platform perfect for handling failures and event-driven automations. So when your Cron job fails, it can retry or notify an operator of the failure.
OpCon is packed with automation features that ensure your critical operations are executed on time, every single time.
It’s also worth pointing out that Workload Automation Software can be an effective Linux Cron and docker Cron alternative.