HostMonster Web Hosting Help

Specify a Cron Job to use a Specific php.ini File

Summary

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:


Some scripts executed with a Cron Job requires 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.

Knowledgebase Article 76,571 views bookmark tags: command cron cronjob crontab custom line optimizer php zend (updated 838 days ago)


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

Error Log receiving this error: PHP Warning: Zend Optimizer for PHP 4.4.x cannot be found (expected at '/usr/local/Zend/lib/Optimizer-2.5.10/php-4.4.x/ZendOptimizer.so') - try reinstalling the Zend Op (updated 1150 days ago)
Knowledgebase Article 49,619 views tags: found optimizer zend

How do I enable the Zend Optimizer on my account? (updated 1147 days ago)
Knowledgebase Article 66,795 views tags: optimizer php zend

This article will explain how to run php and other file types using Cron jobs. (updated 16 days ago)
Knowledgebase Article 254,195 views tags: cron file jobs php

Related Help Content

This article will explain how to setup, remove, or edit a Cron Job. (updated 834 days ago)
Knowledgebase Article 155,140 views tags: cron crontab job

Learn how the Cron Job tool can help you automate the scripts on your web site. (updated 34 days ago)
Video "How-to" Tutorial 143,486 views tags: cpanelutilities cron

We need to execute a Perl script from inside a PHP page and display the results as part of the page. We tried the 'virtual' command but the server returns: blank. (updated 2053 days ago)
Knowledgebase Article 56,250 views tags: perl script

How to run cron jobs at a specific "local" date and time. (updated 1025 days ago)
Knowledgebase Article 36,635 views tags: cron time

I get this with some of my php files: Fatal error: Unable to read X bytes in /home/user/public_html/myfile.php on line Y (updated 2054 days ago)
Knowledgebase Article 87,922 views tags: php unable

This article will instruct you how to import a database from the command line (SSH). (updated 18 days ago)
Knowledgebase Article 391,091 views tags: database mysql ssh

I'm trying to configure an application (phpList) and it requires that I enter (in config.php) a username and password for a POP3 account to handle bounces. I keep getting a POP3 error and it can't log (updated 2066 days ago)
Knowledgebase Article 70,513 views tags: list mail php phplist

This article will instruct you how to export a database from the command line (SSH). (updated 624 days ago)
Knowledgebase Article 432,723 views tags: database mysql ssh