Here is a step-by-step on how you can setup a cronjob in cpanel
- Under the Advanced section, click on Cron Jobs
- On the next page you will see Add New Cron Job at the bottom portion of the page. On the page it lists some example how you would setup a cronjob.
- For this example, we will setup a cronjob that runs every hour. We can select under the Common Settings -> Once Per Hour. Then we scroll down to the bottom in the Command field, we would fill in our path to our script. Since our script is PHP, we would need to use the php binary path as well.
/opt/cpanel/ea-php71/root/usr/bin/php /home/your_cpanel_username/public_html/my_cron_job.php >/dev/null 2>&1
In the above example, we called the PHP binary for PHP7.1 (/opt/cpanel/ea-php71/root/usr/bin/php
). If you want to use another php version, simply change the php71 to another number, such as php74 etc..
then the path to our script is (/home/your_cpanel_username/public_html/my_cron_job.php
)
Lastly, we don’t want to receive any notification on the cronjob status so we add the following into the command(>/dev/null 2>&1
)
Click the Add New Cron Job button at the bottom once you are ready and you are all set!