How to setup a Cronjob in cPanel

Published by: 0

If you want a task to be run at a scheduled interval, then you will need to set a cronjob in your cPanel account.

1) Log into your cPanel account. How to login to cPanel

2) Locate the Advanced section and select Cron Jobs

3) Scroll down and you should see the following section. In the Common Settings there would be a few presets you can use. Which should be sufficient in most cases. If you need to setup a cronjob at a specific time, here is a simple guide.

Minute: To run at every minute */x, substitute the x for the minute interval. For example; every 15 minutes cronjob would be

*/15 * * * *

To run at a specific miunte, use 0-59. For example if you want to run at 15,30,45 then you would enter 15,30,30 in the minutes field. The whole cronjob would look like

15,30,30 * * * *

Hour: Similar to minutes, to run at regular hour interval. */x

To run at a specific hour; then use 0-23 in the hours field

Day: To run on every day, use

*

To run on every 2 days, use

*/2

To run at a specific day, use 0-30/31 (depending on the month). For example if you want to run at the 1st and the 15th of everything. It would be

1,15

Month: To run every third month

*/3

To run on January and September.

1,9

To run on specific month. Use

1-12

Weekday: Weekday, use

1-5

Weekend, use

6-7

Monday, Thursday, Saturday, use

1,4,6

Run on specific day, use the variable

1-7

Command: This is where you fill in the command you want to run. Remember you will have to call the script’s binary file first. For example, to run a PHP file you would have to call the PHP binary (/usr/local/bin/php)

4) The follow is an example to run the script located in /home/demodomain/public_html/cronjob.php .

At every 15,45th minute, every 2 hours, on the 10th, 20th and 30th day of the month, every month.