0

I recently modify the "include_path" var in my php.ini file. Before you ask, I restarted the apache service. The change work for every pages we access from a web browser.

The problem is the cron jobs doesn't seems to consider that change. When I do a phpinfo() inside the cron job, it uses the same php.ini file than the web server and it is the one I changed, but the value beside "include_path" is the old one.

So is there a way to "restart" crontab? Or maybe there is another problem?

Marm
  • 863
  • 2
  • 15
  • 30

2 Answers2

1

Several systems use a separate php.ini file for web and CLI. You will need to make changes in that one as well: How to find the php.ini file used by the command line?

The easiest way to find this file is to run this at the command line: php --ini which will result in output like this:

user@computer:~$ php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d

What you see as "Loaded Configuration File:" is where you need to add your changes.

EDIT: Another option, is in your CRON script use set_include_path() to make the change at runtime.

Community
  • 1
  • 1
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
  • Thank you for the other option. I have a lot of scripts to change, but if I don't find a better solution, I'll use it. – Marm Sep 04 '12 at 18:15
  • When I've done your command, I saw an error in the php.ini file, I've corrected it and now it works fine. Thank you. But is it normal that it's working fine with an error form the web browser? – Marm Sep 04 '12 at 18:19
  • @Marm You probably have *error_reporting* set to ignore it, or *display_errors* turned off. http://php.net/manual/en/errorfunc.configuration.php – Jeremy Harris Sep 04 '12 at 18:21
0

PHP generally has two .ini files. One for in-webserver (SAPI) and one for command-line (CLI) usage. If you modified only the SAPI one, then anything running from CLI (e.g. cron jobs) will not see the change.

do a php -i at the command line to see where PHP is looking for its ini file while in that mode.

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • I've done it and it is the same location, but a different include_path value than the 2 others... – Marm Sep 04 '12 at 18:06