Cron Jobs with PHP and other File Types
If you are using assistive technology and are unable to read any part of the HostMonster website, or otherwise have difficulties using the HostMonster website, please call 866-573-HOST and our customer service team will assist you.
Skip to main content

HostMonster Web Hosting Help

Cron Jobs with PHP and other File Types

Overview

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.



Important: The lines below are examples of command lines. Bold sections must be changed.

Depending on the home directory your account resides on you may need to adjust /home/ to /home#/. 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.

Cron Jobs with PHP and other File Type

Please note: We will be updating to PHP version 8.0 in batches beginning in 2022. Keep an eye out for communications on when your account will be updated and what changes, if any, you will need to make. For more information on updating content for PHP compatibility, read our guide on What to do if your Site Does not Work with Newer Versions of PHP. To learn more about what is changing with PHP 8.0, please see PHP.net's release notes.

PHP

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:

            /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

It is good practice to not type your password out in the following commands but to use the -p flag alone and have the system prompt you for the password. This is why 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
            
Knowledgebase Article 525,206 views bookmark tags: cron file jobs php


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.
Knowledgebase Article 226,499 views tags: command cron cronjob crontab custom line optimizer php zend

How to run cron jobs at a specific &quot;local&quot; date and time.
Knowledgebase Article 177,169 views tags: cron time

This article will explain how to setup, remove, or edit a Cron Job.
Knowledgebase Article 376,125 views tags: cron crontab job

Related Help Content

Learn how the Cron Job tool can help you automate the scripts on your web site.
Video "How-to" Tutorial 349,303 views tags: cpanelutilities cron

This article will explain how to add a PHP handler to your .htaccess files. This is useful if you want to customize the version of PHP that runs your PHP files.
Knowledgebase Article 408,493 views tags: htaccess php

This article will explain how to create MIME types.
Knowledgebase Article 155,131 views tags: create custom extensions files mime types

The php.ini file can be viewed from a web browser.
Knowledgebase Article 156,703 views tags: exploit hide php prevent

This article will explain how to utilize GZip through the file manager.
Knowledgebase Article 232,553 views tags: archive compress compression decompress file gzip management zip

How do I increase my file size limit in my PHP application?
Knowledgebase Article 636,890 views tags: optimize php upload uploads

This article will outline which PHP PEAR Packages are installed and how you can install additional PHP PEAR Packages.
Knowledgebase Article 191,809 views tags: package pear php

This article explains how to enable FastCGI for PHP applications.
Knowledgebase Article 165,939 views tags: fastcgi php

This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here