Loading...

Knowledge Base
Switch to Bluehost and get money back
Migrate your WordPress website from your current host and we'll cover the costs.

How to Set Up Cron Jobs with PHP and Various File Types

This guide offers detailed examples of commands for setting up and managing Cron Jobs. For further insights and explanations on Cron Jobs, explore our series of articles dedicated to Cron Job configurations and best practices by clicking Related 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: The minimum PHP version on our Shared hosting servers is currently at 8.1. 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

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

Related Articles

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.

Did you find this article helpful?

 
* Your feedback is too short

Loading...