Scroll to top

It is very easy to set up a cron job in cPanel.

Cron jobs are scheduled tasks that the system runs at predefined times or intervals. Typically, a cron job contains a series of simple tasks that the system runs from a script file.

 Note: Exercise caution when you schedule cron jobs. If you schedule them to run too often, they may degrade your server’s performance.

Please follow the given procedure to setup the cron in cPanel.

1. Select the “Cron Jobs” tab in cPanel. You can do this either by searching for it or by finding it in the “Advanced” menu.

cron job search

2. Add a cron email.

The Cron Email section of this interface allows you to specify an email address at which you would like to receive notifications whenever your cron jobs are run. To specify an email address:

  • Enter the email address at which you wish to receive the notifications in the email field.

Click the Update Email button.

cron job email noti

3. Add a new cron job.

cron job add a new cron job

For this first configure the interval at which you wish to run the cron job.

  • Common Settings— This menu allows you to select a commonly used interval without having to specify settings for the minute, hour, day, month, and so on.
  • Minute — Use this drop-down menu to select the number of minutes between running the cron job, or the minute each hour on which you wish to run the cron job.
  • Hour — Use this drop-down menu to select the number of hours between running the cron job, or the hour each day on which you wish to run the cron job.
  • Day — Use this drop-down menu to select the number of days between running the cron job, or the day of the month on which you wish to run the cron job.
  • Month — Use this drop-down menu to select the number of months between running the cron job, or the month of the year in which you wish to run the cron job.
  • Weekday — Use this drop-down menu to select the day(s) of the week on which you wish to run the cron job.

  General cron job format is as follows:

[path to environment] [Path to script] [Script parameters]

 For example, if you want to run PHP script located in public_html directory, the correct cron command will be:

/usr/local/bin/php /home/cPaneluser/public_html/yourscript.php

or if you want to use relative path (different commands are divided by “;”):

cd /home/YourcPuser/public_html/; /usr/local/bin/php yourscript.php

For Python and Perl scripts there is no need to use full path to environment, environment interpreter directive will be enough on shared servers.

python /home/YourcPuser/public_html/yourscript.py

perl /home/YourcPuser/public_html/yourscript.pl

Alternatively you can just use curl request as cron job command for the same purpose:

curl “http://yourdomain.com/script.php?argument1=arg1&argument2=arg2”
curl “http://yourdomain.com/script.py”
curl “http://yourdomain.com/script.pl”

However unlike first method, curl-based cron jobs will work only if URLs specified in curl requests are resolving, e.g. DNS records for the domain are correct and running.

Post a Comment

Your email address will not be published. Required fields are marked *