0

我正在设置一个 crontab。直接访问 php 文件(domain.com/file-path/file.php)时,它工作得很好。当通过 shell (php -f /var/www/vhosts/domain.com/file-path/file.php) 访问它时,我到处都遇到包含文件错误。它与设置为的包含路径有关: (include_path='.:')

有没有我可以通过 shell 来设置 include_path 的参数?或者我可以在 file.php 中添加什么来修复错误?我试图避免浏览与此相关的所有文档并将包含路径修复为绝对路径。

谢谢!

4

2 回答 2

1

尝试通过获取所有配置文件来复制您的登录环境,或者查看当前设置的 include_path 并在使用 php 之前适当地设置它。任何一种方法都需要您编写一个简短的脚本

于 2010-08-25T14:10:59.657 回答
0

您可以修改您的 cron 条目以首先更改到适当的目录,然后执行命令:

cron: * * * * * cd /home/user/rest/of/path ; /usr/local/bin/php file.php
于 2010-09-27T12:52:51.797 回答