LB Hosting

Knowledgebase

How do I specify a cron job to use a specific php.ini file?

Problem:

Sometimes, certain scripts require a specific php.ini file to be used. One example of this would be the need to access Zend Optimizer when running a php script through a cron job.

Solution:

When executing a PHP script from the command line, you can use a custom php.ini file. 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

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

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.

Keywords: custom php.ini Zend Optimizer specify certain php cron crontab cronjob command line



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read

Language: