Web Hosting Talk







View Full Version : How to setup Cron Job in cPanel


Netshop-Isp
10-23-2010, 09:40 AM
Many people are yelling that they cannot configure the cron jobs (a.k.a crons) properly.
Here is a short tutorial which will help you set them. I have tried my best to explain the concept but there can be more advanced configurations.

Basically you will want to run a PHP script file in specific intervals. Suppose you want to execute a php file every 5 minutes.

There are 6 basic setups to get your Cron job setup and running:

Step 1:
Login to your cPanel account. If you have forgotten your username or password you will need to contact your web hosting provider.

To access the Cron Jobs Menu, click on the corresponding icon located on the main screen of your cPanel interface (you may need to scroll down the page a bit).

Step 3:
Enter the email address where the cron output will be sent to in the corresponding field.

Step 4:
Select how often you wish the command to be run by selecting an option in each of the boxes.

Step 5:
Enter the command you wish the cron job to run in the blank field next to the Command to run label.

Step 6:
Click on Save Crontab to save your changes and set up your cron job.

RSkeens
10-27-2010, 09:23 PM
Moved to tutorials.

S4m4N
03-18-2011, 05:53 PM
Pay attention to security...
users can run command with this feature.
I would recomment to disable this feature via whm - feature manager
if someone to setup a cronjob you can do it easily with ssh
crontab -u username -e
service crond restart

riceboi1230
06-11-2011, 12:13 PM
Do these also work with from job backups?

Gurusms
09-27-2011, 02:30 AM
Hi,
I want to have the same cron job to be run for multiple users at different intervals. Say 5 users, after every 20min after first occurance. Please let me know is it possible? if yes please provide the details.

Netshop-Isp
09-27-2011, 03:09 AM
Hello Gurusms,

unfortunately this is impossible to be achieved from cPanel (not even from WHM). The only way to do this is to login as root on your server and set the cronjob from there:

crontab -u -e username

The entry for crons would be in the path - /var/spool/cron

You can find more info about it here:
http://ss64.com/bash/crontab.html
(http://ss64.com/bash/crontab.html)http://ss64.com/bash/cron.html (http://ss64.com/bash/cron.html)