How to set 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.
Cron Email feature sends an email with the output of your command, if any, every time the Cron job runs.
[1] Login to cPanel
[2] Cron Email setion
[3] Disable email notifications
To disable email notifications for a single cron job, perform the following steps:
If you don’t want to receive any email notifications, you can instruct the server to redirect the output to /dev/null by placing the following code after your command: /dev/null 2>&1
[4] Click on Save
[5] Add Cron Job
Select the interval at which you wish to run the scheduled task from the appropriate menus, or enter the values in the text boxes.
If you want to run a PHP script located in the public_html directory, the correct command will be:
/usr/local/bin/php /home/cPaneluser/public_html/yourscript.php
/usr/bin/php -q /home/cPaneluser/public_html/yourscript.php
You can set the timings. Please make sure that it must be set above 45 minutes timing interval.
After adding the new scheduled task , cPanel will show you a message saying that it was created successfully, or it will show you an error message if something went wrong. If all went well, you should see your new cron job under “Current Cron Jobs.” You can edit or delete your cron job by clicking on the appropriate link under “ACTIONS.”
Edit a cron job :
To edit a cron job, perform the following steps:
[a] Locate the cron job that you wish to edit and click Edit.
[b] Edit the settings that you wish to change and click Edit Line.
NOTE: If your script does not generate any output, it is possible that notification emails are not sent either, however, the cron job is working.