Casbay Knowledge Base

Search our articles or browse by category below

What Do I Put for the Cron Job Command ?

Last modified: October 1, 2022
Estimated reading time: 2 min

What Do I Put for the Cron Job Command ?

The commands below are compatible with all Linux Web Hosting plan includes Shared Hosting, VPS Hosting and Dedicated Servers with Easy Apache 3 installed; these commands will not work on Windows Hosting or VPS with Plesk.

Command line examples only! Bold sections must be changed.

Note: You may need to adjust /home/ to /home#/ depending on the home directory on which your account resides. To view the home directory for your account simply view the stats column on the main cPanel page of your account, and look for the home directory.

PHP

EasyApache 3

Command to run a PHP 7.0 cron job:

/opt/php70/bin/php /home/username/public_html/cron.php

Command to run a PHP 5 cron job:

/php/home/username/public_html/cron.php

Command to run a PHP 4 cron job:

/usr/local/php4/bin/php/home/strong>username/public_html/cron.php

Optional flags are sometimes required for a PHP cron job:

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

 

Command to use a specific php.ini file:

php -c /home/username/public_html/php.ini /home/username/public_html/myscript.php

Command to GET a remote file:

/usr/bin/GET http://www.example.com/file.php

Perl

Command to run a CGI cron job:

perl /home/username/public_html/cgi-bin/file.pl

SSH

Command to run a code script cron job:

/bin/sh /home/username/public_html/file.sh

MySQL

Note: It is a good practice to not type your password out in the follow commands but to simply use the -p flag alone and have the system prompt you for the password. This is way your password stays secure and is never on the server as plain text.

Command to import a database:

mysql -u mysql_user -ppassword database_name < backup.sql


Command to export a database:

mysqldump -u mysql_user -ppassword database_name > backup.sql

How Do I Create and Delete a Cron Job?

Cron jobs run scheduled commands at specific times. The Cron Jobs tool in cPanel is helpful for setting up automated maintenance and other unmanned server duties.

Create a Cron Job

1. Firstly, log into cPanel.

2. Secondly, click Cron Jobs in the Advanced section.

3. Next, Under Cron Email, make sure the current email address is valid. If not, enter a new, valid email and click Update Email. You will receive an email after the cron job has finished.

4. Under Add New Cron Job, use the Common Settings drop-down menu to choose from a list of regularly used intervals; or set the frequency of your cron job by using the drop-down box next to each time unit. Common settings range from every minute to once a year.

5. Then, enter the desired command in the Command field.

6. Lastly, click Add New Cron Job.

Your cron job will then be execute a file at a certain time, date and repetition, according to the settings you selected.

 
Remove or Edit a Cron Job

1. Firstly, click the Cron Jobs icon in the Advanced section of cPanel.

2. Next, scroll down to the last section called Current Cron Jobs.

3. Then, find the cron job you wish to edit or delete.

4. Lastly, click either Edit or Delete under Actions.

We hope this article helped you to learn about Cron Job command. For more articles, please go to Knowledge Base.

Was this article helpful?
Dislike 0
Previous: What Do I Put Cron Job Command?
Next: All you need to know about cPHulk