Loading...

Knowledge Base

How to Use a Specific php.ini File with Cron Jobs

Learn how to set php.ini for Cron Jobs through this guide. If you need a different explanation of Cron Jobs, please refer to the articles linked below:

Important: You must know Linux commands well before using cron jobs effectively. Please check your script with your hosting administrator before adding a cron job.



Cron Job Specific php.ini

When running scripts with a Cron Job, it may be necessary to use a specific php.ini file. This can also be done when executing a PHP script from the Command Line Interface. Using a custom php.ini file can help customize the script execution and achieve the desired result.

For example, you can force a cron job to use a specific php.ini file when a user's code requires access to something such as Zend Optimizer, which is specified in the php.ini file.

php.ini Configuration for Cron Jobs

To specify an alternate php.ini file, you'll need to use the -c flag in your PHP command line.

For example:

 php -c /home/username/public_html/php.ini /home/username/public_html/myscript.php

In this instance,/home/username/public_html/php.ini is the full path to the php.ini file you'd like to use, and /home/username/public_html/myscript.php is the full path to the PHP script you'd like to run. Using your actual username, change the path to the php.ini and the file you intend to run accordingly. Your home directory may be home1, home2, home3, etc.

Note: Check out PHP's support document for a list of php.ini directives.

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...