HostMonster Web Hosting Help
Cron Jobs with PHP and other File Types
Summary
This article will provide examples of different commands you can use in Cron Job. If you need a different explanation on Cron Jobs, please refer to this list of Cron Job articles:
- Cron Job Basics
- Setup or Remove a Cron Job
- Crons Running at Specific Date and Time
- Specify a Cron Job to use a Specific php.ini File
Command lines. Examples only! Bold sections must be changed.
PHP
Command to run a PHP7 cron job:
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
Perl
Command to run a CGI cron job:
perl /home/username/public_html/cgi-bin/file.pl
SSH
Command to run a shell script cron job:
/bin/sh /home/username/public_html/file.sh
MySQL
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 3 (VPS/Dedicated)
PHP
Command to run for a PHP7 cron job:
/usr/php/70/usr/bin/php-cli /home/username/public_html/cron.php
Recommended Help Content


Related Help Content

