HostMonster Web Hosting Help

Cron Jobs with PHP and other File Types


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:

Command lines. Examples only! Bold sections must be changed.

Note: You may need to adjust /home/ to /home#/ depending on the home directory your account resides on. 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.


Command to run a PHP5 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:



Command to run a CGI cron job:

perl /home/username/public_html/cgi-bin/


Command to run a shell script cron job:

/bin/sh /home/username/public_html/


Note: It is 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 3 (VPS/Dedicated)


Command to run for a PHP5 cron job:

/usr/local/php5/bin/php5 /home/username/public_html/cron.php

Command to run for a PHP4 cron job:

/usr/bin/php /home/username/public_html/cron.php

Knowledgebase Article 165,612 views bookmark tags: cron file jobs php (updated 426 days ago)

Was this resource helpful?

Did this resolve your issue?

Please add any other comments or suggestions about this content:

Recommended Help Content

Script executed with a cron job requires a specific php.ini file to be used. (updated 438 days ago)
Knowledgebase Article 66,908 views tags: command cron cronjob crontab custom line optimizer php zend

This article will explain how to setup, remove, or edit a Cron Job. (updated 433 days ago)
Knowledgebase Article 98,005 views tags: cron crontab job

Learn how the Cron tool can help you automate the scripts on your web site. (updated 620 days ago)
Video "How-to" Tutorial 112,410 views tags: cpanelutilities cron

Related Help Content

I have a file with a non-standard extension, how can I get your server to display its contents? (updated 65 days ago)
Knowledgebase Article 80,798 views tags: extensions file mime types

How to run cron jobs at a specific "local" date and time. (updated 624 days ago)
Knowledgebase Article 27,965 views tags: cron time

How do I enable PHP 5 for my PHP applications? How do I change to PHP FastCGI? How do I use a single php.ini file? (updated 223 days ago)
Knowledgebase Article 128,816 views tags: config php

What are MIME Types? How do I create custom MIME Types? (updated 1618 days ago)
Knowledgebase Article 48,186 views tags: create custom mime types

The php.ini file can be viewed from a web browser. (updated 697 days ago)
Knowledgebase Article 47,010 views tags: exploit hide php prevent

This article will outline which PHP PEAR Packages are installed and how you can install additional PHP PEAR Packages. (updated 184 days ago)
Knowledgebase Article 52,546 views tags: package pear php

PHP vs PHP single php.ini vs PHP with FastCGI (updated 697 days ago)
Knowledgebase Article 108,758 views tags: configuration php server

How do I increase my file size limit in my PHP application? (updated 183 days ago)
Knowledgebase Article 170,395 views tags: optimize php upload uploads