Updated on Nov 6, 2019
Cron is a Linux program (or other UNIX type OS), used for scheduling your time-based jobs. You can use the program when you want to automate specific repetitive tasks on your server, ultimately saving you time.
What we will cover:
Cron jobs are typically scheduled to run at specific dates or times. The ‘job’ is a script that usually performs an update task. Some examples of such tasks are:
The cron job format may seem a bit complicated and overwhelming for first-timers, but this guide is to help you by breaking the whole process down into easy-to-follow steps. Keep in mind that the Cron job is a helpful and powerful tool that can save you time daily.
A Cron Job needs to have the following components:
The things you will need before setting up a cron job in cPanel are:
There are four steps that you need to follow when setting up a cron job in cPanel.
To log in to your cPanel Account, if you are a FastComet customer, you need to go to your Client Area (my.fastcomet.com). From there, you click on the cPanel icon:
And here you are!
Once you are in the cPanel, you will be able to find Cron Jobs. You can do that quickly if you type it into the cPanel search bar. Go to the cron job menu by clicking on the link or the icon:
If you want to get notified when your cron jobs run, you need to enter your email in the “Cron Email” section. This is not a necessary step before you continue, but it’s recommended.
Those email notices would be handy to indicate whenever something goes wrong. For example, if you don’t receive an email after you have subscribed for cron job updates, you will know that something is not quite as planned.
Not all scripts that are executed via cron jobs provide outputs or send emails. That depends on the PHP code you are using.
Nevertheless, if you have a lot of cron jobs, such emails could start to irritate you.
To receive an email whenever a cron job runs, enter your email address in the Email field:
Note that there could be cases your default email address for the specific cPanel account is pre-set to receive the cron job notices. If you no longer wish to receive the notices, click on Update Email without inputting anything in the Email field.
To set up your cron job in cPanel, scroll down from the email options, and find the Add New Cron Job section:
Before you start configuring the individual time and date elements, find and click the Common Settings drop-down:
You will need to follow some steps in regards to the timings of the cron job. You can select your desired cron job interval from the appropriate menus, or you can enter your values:
In the Command text box, you can enter your desired command that you want to run via the cron job.
You have to specify settings for the Minute, Hour, Day, Month, Weekday, and Command text boxes. Be cautious whenever using the ‘rm’ command in a cron job. If you don’t declare the proper options, you could delete your home directory data (you definitely don’t want that).
The final field in Add New Cron Job is Command. It’s the field where you enter the path to the file that contains the server command which you want to run at the specified times.
After entering the path, click the button Add New Cron Job.
If you wish to execute a PHP script, the command would have to consist of two parts:
/usr/local/bin/ea-php# - EasyApache (VPS/Dedicated CPU Servers without CloudLinux).
/opt/alt/php#/usr/bin/php - CloudLinux.
The # will have to be replaced with the appropriate PHP version. For PHP 7.3 it is
ea-php73/php73, for PHP 7.0 — it is
When you are successful in setting up your cron job, you will see the following message: ‘cPanel successfully added the cron job.’
Sometimes you might need to edit or delete one or more of your cron jobs. In such cases, you need to:
You might have been surprised, but as you can see, setting up cron jobs via cPanel is quite a straightforward process. If you find that cron jobs are useful to you, you should start thinking about other uses for them.
However, in case anything goes wrong after setting a cron job, and you don’t know what to do—contact our 24/7 technical support team. Open a support ticket, and you can be sure that our experts will assist you as soon as possible.
We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!