Cron is a Linux daemon used to automate scheduled tasks (cron jobs) on a server. Cron jobs are very useful if you are running repetitive tasks on your website. For instance, if you a have a mailing list and you want to send a newsletter (e.g. daily), cron jobs can invoke the email sending functions without any manual input.
The Cron function is also used on subscription-based websites to create and send automatic recurring invoices and reminders about accounts expiration. Another possible usage is creating backup copies of website databases.
So, you can virtually automate any tasks on your website using the technology. In this guide, we are going to show you how to configure and setup cron jobs on your cPanel account.
Special Note: You can run a Cron job using cPanel. Most hosting services offers cPanel for free as part of their plan. If for some reason yours does not, consider switching to a hosting service. You will find the world’s best web hosting services on Hostadvice, along with expert and user reviews.
- A domain name e.g. www.example.com
- A web hosting account that supports cPanel
- cPanel username and password.
Step 1: Log to your cPanel Account
You can access your cPanel account by typing www.example.com/cPanel . Remember to replace ‘example.com’ with the primary domain associated with your hosting account. Then, enter your cPanel username and password as shown below:
Step 2: Search for cron jobs scheduler
Once you are in the dashboard enter ‘Cron Jobs’ on the text box that reads, “Find functions quickly by typing here:” and click the link that appears as shown below:
Step 3: Updating cron email
On the next screen, you will see an option for setting up cron jobs and you can choose whether you want to receive an email once a cron job runs. To avoid getting a lot of emails in your inbox, you may enter your address here temporary for testing purposes and delete it once everything is up and running.
Click on ‘Update Email’ to save the changes.
Step 4: Setting up a cron job
The next step is to add your first cron job by specifying the timings and the command as shown below:
Cron job timings
Minute: The exact minute when you want the cron job to run. It takes the values between 0 and 59
Hour: This field accepts a value between 0 and 23. It specifies the exact hour when you want the cron to run e.g. 0 means the cron job will run exactly at midnight.
Day: You can enter any value between 1 and 31. This field represents the day of the month. For instance, to run a cron job on the mid-month, enter ‘15’ as the value.
Month: Takes the value between 1 and 12. For instance, to schedule, a task for the month of October, use ‘10’ as your value.
Weekday: This is the day of the week; the allowed values are between 0 and 6(Sunday to Saturday)
Command: Enter the command that you want to execute here (e.g. ‘wget https://www.example.com’)
Step 5: Cron job examples
To schedule a task once per minute use the below settings
To run a cron job once at midnight, use the settings below:
Commas on commands
To run a command on the 1st and 15th day of the month, refer to the below settings:
To run a command on 3 am on the 1st day of January, use the settings below
That is the basic procedure of setting up cron jobs from your cPanel. You can tweak the settings as required depending on your timings. Remember to click the ‘Add New Cron Job’ once you have entered the right values in all fields. Cron jobs are very useful especially when running web applications on the internet. You will need them in one way or another to automate repetitive tasks and we believe this guide has shown you the basics of doing the same.
Check out the top 3 cPanel hosting services:
- Want to get top recommendations about best hosting? Just click this link!