How to Set a Cron Job to Use a Specific php.ini File

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.

Specifying the 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

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.

Note: Your home directory may be home1, home2, home3, etc.

  • 0 Users Found This Useful
Was this answer helpful?

Also Read

Custom Error Pages

What are Custom Pages for Errors? When your website generates an error, such as a 404, it...

What Are Cron Jobs?

cron is a Linux utility which schedules a command or script on your server to run automatically...

Error Pages Codes

What are Error Codes? All HTTP requests (the type of requests generated by your browser when...

Setting a Cron to Run at a Specific Date and Time

In order to correctly set joudiSoft's servers to perform a desired task in the form of a cron...

How Do I Create and Delete a Cron Job?

Cron jobs run scheduled commands at specific times. The Cron Jobs tool in cPanel is helpful for...