BuycPanel Blog

BuycPanel Blog

Latest news and updates

12/15/2014 – Using Cron Jobs to your Advantage

Posted by Jamison on 15 12 2014.

A cron is a Linux command or script you can set to perform a specific task on your server during a specific time and date or regular time intervals. This is useful for when you want some tasks done but can’t be there to do it all the time, like sending email notifications, running scans or deleting temporary files.


These can also be helpful when you hate carrying the same tasks all over and over again.


The cron itself is the command or script line, the cron job is the scheduled task.


How to create a cron job


  1. Log into cPanel.
  2. Go to the Advanced section and click Cron Jobs.
  3. Make sure the current email address under Cron Email is valid. If it isn’t enter a valid email and click Update Email. You should get an email after the cron job is complete.
  4. Under Add New Cron Job, use the Common Settings drop-down menu to choose from a list of regularly used intervals. You can also set the frequency of your cron job by using the drop-down box next to each time unit.
  5. In the Command field, enter the command you want carried out.


You cron job should be executed during the programmed times. Cron jobs can be set to run task by minute, hour, day, week, month or even year, so it’s very convenient.


What to put for the cron job command


The following commands are only compatible with Linux hosting as well shared, reseller, VPS, and Linux Dedicated Servers. They will not work on Windows Hosting or VPS packages with Plesk.


For the examples below, substitute “username” for your actual username (without quotes) and while fill up “cron.php” with the actual script name (also without quotes). You might also need to adjust /home/ to /home#/ depending on the home directory on which your account resides. To know your home directory, view the stats column on the main cPanel page of your account then look for the home directory.




Command to run a PHP 5.5 cron job:

/opt/php55/bin/php /home/“username”/public_html/“cron.php”


Command to run a PHP 5.4 cron job:

/opt/php54/bin/php /home/“username”/public_html/“cron.php”


Command to run a PHP 5.3 cron job:

/opt/php53/bin/php /home/“username”/public_html/“cron.php”


Command to run a PHP 5.2 cron job:

/opt/php52/bin/php /home/“username”/public_html/“cron.php”


Sometimes optional flags are required for a PHP cron job:

php -q /home/“username”/public_html/“cron.php”


Using crons to import/export databases in MySQL


It’s advisable not to type your password out in the follow commands, just simply use the -p flag alone and have the system prompt you for the password. Always secure your password!


How to import a database:


mysql -u mysql_user -ppassword database_name < backup.sql


How to export a database:


mysqldump -u mysql_user -ppassword database_name > backup.sql


How to remove or edit a cron Job


  1. Go to the Advanced section of cPanel and click the Cron Jobs icon.
  2. Scroll down to the last section called Current Cron Jobs.
  3. Find the cron job that has to be edited or deleted.
  4. Under Actions, for the appropriate cron job, click either Edit or Delete.