Cron jobs are scheduled tasks in Unix-like operating systems that are executed automatically at specified times or intervals. They are managed by a service called "cron" (short for "chronograph"), which runs in the background and checks for tasks to be performed at specified times.
The "Cron Jobs" feature in cPanel allows you to configure a script for automatic execution for an indefinite period of time. This feature is particularly useful if your website has to perform some automated tasks on a regular basis. Such is the case with most of the Opensource applications used as platforms for building websites.
In the next lines of this tutorial, we will show you how to add a new Cron Job and how to manage any already configured such. Let us begin!
As we have mentioned, "Cron Jobs" is a feature of cPanel, and to be able to use it, you will have to be logged into the cPanel service. Once you have done that you will see a complete list of all the features cPanel has to offer.
To access the "Cron Jobs" feature, you can either use the search tool provided at the top of the page, or you can look for the "Advanced" features group and within that group, you will see the "Cron Jobs" feature.
Upon clicking on the feature, cPanel will redirect you to the default page of Cron Job page same. There you will find a brief explanation of what the "Cron Jobs" feature is and also all other tools you will need to manage the "Cron Jobs" of your Web Hosting Account.
By default, the execution output for each Cron Job will be sent as an email to the default email address for your Web Hosting Account. If you would like to receive the output on another email account, you will need to configure it in the "Cron Email" section.
Using the "Email" text field, by typing in the desired email address, and then pressing the "Update Email" button, you will be able to set a new email address for receiving the output from the Cron Jobs executions.
We strongly recommend when configuring the Cron Email to set up an email account associated with your Web Hosting Account. You can create a new email account by following our tutorial "How to completely manage Email accounts in cPanel?".
Another thing you should consider is that you can completely disable the emailing of the output from your Cron Jobs execution. To do that, you will need to add the following string at the end of the Command for your Cron Job:
>/dev/null 2>&1
Or for example, if the command you would like to execute on a regular basis is:
/usr/local/bin/php /home/hostarma/public_html/script.php
Then, after you add the above mentioned sting at the end, the complete command will become:
/usr/local/bin/php /home/hostarma/public_html/script.php >/dev/null 2>&1
As you can see, disabling Cron Job output is relatively simple. Now let us add a new Cron Job.
To add a new Cron Job, you will have to scroll down a bit, and right after the "Cron Email" section, you will find the "Add New Cron Job" section. There you will be able to fully configure the script you will need to be executed regularly. Let's review the settings you will have to configure:
Once you are ready with the configuration please click on the "Add New Cron Job" button so you can save the configured command.
We recommend configuring a Cron Job for a period not shorter than "Once per five minutes */5 * * * *" or otherwise, depending on the executed command you risk overloading your Web Hosting Account.
Depending on the type of script you would like to execute or, more precisely, on the used programming language, you will have to configure different commands. For example, if the executed script is PHP based, you will need to add the path to the PHP binary before the path to the executed script:
/usr/local/bin/php
Here are the paths to the other typically used binaries:
Please note that executing cron jobs for virtual environments is not an option that is available.
We always advise testing the command first before adding it as a Cron Job. To do that you will simply need to login over the SSH service for your account and simply paste the whole command in order to review the command's output and the execution.
Once added, the Cron Job will be listed in the next section called "Current Cron Jobs". There you will be able to further manage your existing Cron Jobs.
To Edit an existing Cron Job, please click on the "Edit" link next to every Cron Job on the list. This will bring up an editing interface that is the same as the one you have used when adding the Cron Job, however this time with values already configured.
Once you are done editing the Cron Job, please click on the "Edit Line" button at the bottom of the editing interface.
To Delete an existing Cron Job, please click on the "Delete" link next to the "Edit" link for every Cron Job on the list. This will bring up a confirmation which after confirmed will remove the Cron Job you have chosen.
As you can see adding new Cron Jobs or managing existing ones is not a hard task. Still, if you need any further information on the matter or in case you are facing some sort of difficulty adding new Cron Jobs, please do not hesitate to submit a support ticket and check with our experienced Technical Support Crew since they will be able to assist you with every Cron related issue.
Nikola is an accomplished tech-savvy extraordinaire with over six years of experience in the web hosting field. He started as a customer care representative and quickly rose the ranks to become a support supervisor and, eventually - the head of the technical department in HostArmada. His deep understanding of the client's needs, combined with his technical knowledge, makes him the perfect man to create the ideal harmony between client satisfaction and professional problem-solving. You will often find him creating helpful tutorials, articles, and blog posts that help existing customers get around.