The Purpose of Cron Jobs within Webapps
Cron Jobs — We’re quite certain most of you have no clue what we’re referring to. So in a nutshell, its a standard method of scheduling tasks to run on a web server. Cron is a service running in the background that will execute commands (jobs) at a specified time, or at a regular interval.
For instance, you might have a script that produces web sales reports that you want to run once a day automatically at 5:00 AM.
For the sake of this article, we will aim to elaborate in layman's terms and steer clear from techno-speak. So let's dive a little deeper. What are crons? Why should use them? What the benefits and the downsides?
WHAT ARE CRON JOBS?
When it comes to websites and web applications, we need to break down the architecture slightly to explain where Cron Jobs fit in.
So firstly we have the web application’s source code (what the website was coded or developed in) which is added to a server (think of it being installed on the server). This server is a machine on the internet that is accessible to everyone.
Now this server has many other features that can be used and in this instance, it can also run automated tasks that can be scheduled. These are called Cron Jobs. Each Cron Job specifies when it needs to be executed and what needs to run.
WHEN CAN THEY RUN?
In terms of when things can run, this is totally customisable, for example every two hours or daily at 20:00 or monthly on the 20th day of the month at 12:00, etc. You kind of get the idea.
This gives us loads of flexibility in terms of scheduling dates and times that these automated procedures need to run.

WHAT CAN WE RUN?
The great thing about Cron Jobs is that we can run almost anything. The Cron Job effectively calls scripts (think of them as programs or applications) on the server that then perform whatever the task is that’s required.
This is where our custom development magic comes into play. As these Cron Jobs are connected to a project (website or web app), typically the requirements for the Cron Job vary highly from project to project and are entirely unique and customised to the project in question.
So to sum up what we can run, well pretty much any functionality that we can develop. Below we’ll list some examples that you can go through and understand more practical examples.
TELL ME ABOUT THE BENEFITS
- The main and most obvious benefit is to be able to set up automated tasks and processes to run when you need them to be executed. You can control the minute, the hour, the day, etc. when it will execute.
- No reliance on humans. As Cron Jobs are automated and run by the server there is no dependence on a human to make sure that the process runs when it should as the Cron Job will run at the exact times that are specified without fail.
- When the Cron Job isn’t running, it’s pretty much not doing anything, meaning that it's not occupying memory in your system when it's not running.
- Cron Jobs are reliable and predictable and fairly easy to implement (if you are a developer)
- If the Cron Job fails or exits for some reason, the process will restart when the next scheduled time comes for it to run.
WHAT ARE THE DOWNSIDES?
- The smallest interval is one (1) minute - If a task needs to run every 30 seconds, you can’t do it with a Cron Job, unfortunately. You will need to do this with another development approach.
- Error handling - Typically Cron Jobs don’t have error handling so this is something that needs to be developed and tested to ensure that should errors occur that they are reported and dealt with. There are ways to email the output of the Cron Job so that you can view the outcome but the output of the scripts can be really large and someone needs to monitor this output otherwise it’s a pointless process.
- Logging - Cron Jobs don’t log what is happening and when they run. So if you need to audit why a process failed or went wrong, there won’t be any logs to review. The solution to this is to develop custom logging solutions so that when there are problems these logs can be accessed and reviewed to determine what the issue was and then rectified.
- Cron runs separately from your web application - Therefore may impact the web app. Therefore it’s important to know that a web application has Cron Jobs running and what their purpose is and when they run, to ensure that they don’t negatively impact your web app.
EXAMPLES OF CRON JOBS IN ACTION
We’ve been developing web applications for years and incorporating cron jobs to automate many processes. These are highly valuable as we don’t need to rely on humans to perform certain tasks as the technology does it much better.
We’ve probably developed hundreds of automated processes but here are a few to give you an idea as to how they function and what their purpose is.
- Monthly reminders - These are reminders that get sent to users of a website that have not completed a certain task in a specific month. For example: completing a feedback form.
- Daily feed integrations via API - We often need to get data from third party platforms to incorporate into our client’s websites. For example, getting new stock and importing it into the website.
- Monthly reporting - When it comes to reporting, it’s much more convenient for a user to get sent a report (typically in PDF format) to their inbox, rather than having to login to a website and running some sort of report generation process. In this instance we generate a monthly report at the beginning of the month for the previously concluded month’s activities and we email this to all stakeholders, nice and simple, yet so powerfully effective.
There are literally thousands of uses for automating procedures and you can create as many and customise them as you wish.
A FEW OTHER THINGS TO KNOW ABOUT CRON JOBS
- Fun fact! Cron is the name that is derived from the Greek word, Chronus. We’re pretty sure many developers don’t even know this one!
- Cron Jobs can only run in Unix-like operating systems, such as Linux, which is the most popular operating system for servers. Unfortunately Microsoft servers don’t have Cron Jobs.
- Cron Jobs and the scripts that they run should only be set up by experienced developers or server administrators.
- Setting up the Cron Jobs is typically done through the command line in Linux but certain hosting providers have control panels to administrate your website, providing user-friendly interfaces for managing Cron Jobs without having to know or understand the syntax to create these using linux commands. Again, caution must be used when setting these up.
The Cron Job format is as follows (for those of you who are more technical):
The five-date and time fields are minute, hour, day of the month, month, and day of the week respectively:

A example of a command that runs every 5th minute on the hour (EG: 1:05, 2:05, 3:05 etc.):
5 * * * * /path/to/command
LET’S WRAP THIS UP
Cron Jobs are part and parcel of most complex and custom websites and web applications. They provide a great mechanism to run automated processes. This provides website owners and users with loads of benefits by ensuring that tasks that need to be scheduled and executed get processed as designed.
There are minimal restrictions in terms of the scheduling of the tasks, with lots of flexibility and options available.
The functionality that can be executed is again highly flexible and pretty much any custom-developed scripts will be able to run.
The reliance on humans and the possibility of human error is eliminated through Cron Jobs and their automated nature.
Working with Cron Jobs can be a tricky business so make sure that only experienced web developers develop and set up the Cron Jobs to ensure that there are no errors and mistakes made.
If you are wanting to take your website or web application to the next level, we highly recommend that you consider including Cron Jobs, to extend your functionality and automate your processes.