Specify a Cron Job to use a Specific php.ini File
This article will explain how to set a Cron Job to use a specific php.ini file. 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
- Cron Running at Specific Date and Time
- Specify a Cron Job to use a Specific php.ini File
- Cron Jobs with PHP and other File Types
Some scripts executed with a Cron Job require a specific php.ini file to be used.
When executing a PHP script from a Cron Job (or via the command line), you can use a custom php.ini file. The most common situation where a custom php.ini file is needed is when a user's code requires access to something such as Zend Optimizer, which is specified in the php.ini file.
To specify an alternate php.ini file, you'll need to use the -c flag in your PHP command line.
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