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?

Related Articles

I want to create an addon domain but do not want to change my name servers first.

Email a and request to add one of your domain's current nameservers to...

How to Whitelist Your IP in cPanel for Remote MySQL Access

This tutorial will show you how to whitelist your IP to allow remote MySQL connections for...

How to Upload a File using the File Manager

You can upload your files directly through cPanel using the File Manager. File Manager is a web...

Local, Backup, and Remote Mail Exchanger

This is a setting that tells SignedOn how to handle your incoming emails. We recommend...

How to upload to an Addon or Subdomain

How to upload to an Addon or Subdomain Option 1 In a FTP client enter this information.Host =...