A few very handy Cron Job Commands

In this article, we’ll take you through a set of CRON job commands that you can run on your Linux Hosting:

PHP (If you want to check your PHP version or configuration – Click Here)
Command to run for a PHP 5.4 cron job:
/usr/local/altphp54/bin/php /home/username/public_html/cron.php

Command to run for a PHP 5.3 cron job:
/usr/local/altphp/bin/php /home/username/public_html/cron.php

Command to run for a PHP 5.2 cron job:
/usr/local/altphp/bin/php /home/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

Command to run a CGI cron job:
perl /home/username/public_html/cgi-bin/file.pl

Command to run a code script cron job:
/bin/sh /home/username/public_html/file.sh

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

Custom Installations without Easy Apache (If you have a VPS or Dedicated Server)
Command to run for a PHP5 cron job:
php /home/username/public_html/cron.php

0 Dislikes