简体   繁体   English

php cron作业不会更新php.ini

[英]php cron job doesn't update php.ini

I recently modify the "include_path" var in my php.ini file. 我最近在php.ini文件中修改了“ include_path”变量。 Before you ask, I restarted the apache service. 在您询问之前,我重新启动了apache服务。 The change work for every pages we access from a web browser. 更改适用于我们从Web浏览器访问的每个页面。

The problem is the cron jobs doesn't seems to consider that change. 问题是cron作业似乎没有考虑这种变化。 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. 当我在cron作业中执行phpinfo()时,它使用与Web服务器相同的php.ini文件,这是我更改的文件,但是“ include_path”旁边的值是旧的。

So is there a way to "restart" crontab? 那么有没有办法“重新启动” crontab? Or maybe there is another problem? 也许还有另一个问题?

Several systems use a separate php.ini file for web and CLI. 多个系统将单独的php.ini文件用于Web和CLI。 You will need to make changes in that one as well: How to find the php.ini file used by the command line? 您还需要在其中进行更改: 如何找到命令行使用的php.ini文件?

The easiest way to find this file is to run this at the command line: php --ini which will result in output like this: 查找此文件的最简单方法是在命令行中运行该文件: php --ini ,结果如下:

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. 编辑:另一个选项,是在您的CRON脚本中使用set_include_path()在运行时进行更改。

PHP generally has two .ini files. PHP通常有两个.ini文件。 One for in-webserver (SAPI) and one for command-line (CLI) usage. 一种用于Web服务器(SAPI),另一种用于命令行(CLI)。 If you modified only the SAPI one, then anything running from CLI (eg cron jobs) will not see the change. 如果仅修改了SAPI,那么从CLI运行的任何内容(例如cron作业)都不会看到更改。

do a php -i at the command line to see where PHP is looking for its ini file while in that mode. 在命令行中执行php -i ,以查看在该模式下PHP在哪里寻找其ini文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM