How do I set up Cron Jobs in cPanel?
Cron jobs allow you to automate tasks on your server by scheduling scripts or commands to run at specific times or intervals. This is especially useful for tasks like regular backups, clearing caches, or sending scheduled emails. Follow the steps below to set up a cron job in cPanel.
Log into cPanel:
Access cPanel using your credentials. (Refer to our article: How do I log into cPanel?)
Locate Cron Jobs:
Scroll down to the Advanced section.
Click on Cron Jobs.
Set Up Email Notifications (Optional):
If you want to receive an email notification every time the cron job runs, enter your email address in the Cron Email section and click Update Email.
If you do not want notifications, simply ensure there is no email set, or add >/dev/null 2>&1 at the end of your cron job command to suppress email output.
Add a New Cron Job:
In the Add New Cron Job section, you’ll see a dropdown menu for Common Settings. Here, you can choose a predefined interval for your cron job (e.g., once per day, every minute, every week).
Alternatively, you can manually set the schedule using the fields provided for Minute, Hour, Day, Month, and Weekday. For example:
*/5 * * * * – This will run the job every 5 minutes.
Enter the Command to Run:
In the Command field, enter the command or script you want to run. This can be a PHP script, shell script, or another command. Example:
Replace /home/yourusername/public_html/cron.php with the actual path to your script.
Click Add New Cron Job:
Once you’ve set the timing and command, click Add New Cron Job to save your new cron task.
If you need further assistance, feel free to contact our support team or email helpdesk@elitehost.co.za.
Steps to Set Up a Cron Job in cPanel
Log into cPanel:
Access cPanel using your credentials. (Refer to our article: How do I log into cPanel?)
Locate Cron Jobs:
Scroll down to the Advanced section.
Click on Cron Jobs.
Set Up Email Notifications (Optional):
If you want to receive an email notification every time the cron job runs, enter your email address in the Cron Email section and click Update Email.
If you do not want notifications, simply ensure there is no email set, or add >/dev/null 2>&1 at the end of your cron job command to suppress email output.
Add a New Cron Job:
In the Add New Cron Job section, you’ll see a dropdown menu for Common Settings. Here, you can choose a predefined interval for your cron job (e.g., once per day, every minute, every week).
Alternatively, you can manually set the schedule using the fields provided for Minute, Hour, Day, Month, and Weekday. For example:
*/5 * * * * – This will run the job every 5 minutes.
Enter the Command to Run:
In the Command field, enter the command or script you want to run. This can be a PHP script, shell script, or another command. Example:
/usr/local/bin/php /home/yourusername/public_html/cron.php
Replace /home/yourusername/public_html/cron.php with the actual path to your script.
Click Add New Cron Job:
Once you’ve set the timing and command, click Add New Cron Job to save your new cron task.
If you need further assistance, feel free to contact our support team or email helpdesk@elitehost.co.za.
Updated on: 21/10/2024
Thank you!