我正在尝试让 crontab 运行一个 php 文件,这是 cronjob
10 * * * * /usr/bin/php /var/www/update/ranks.php >> /var/www/update/log/ranks.txt
但是我不断收到错误消息,说所需的文件不存在
PHP Warning: require_once(../mws_products.php): failed to open stream: No such file or directory in /var/www/update/ranks.php on line 2
PHP Fatal error: require_once(): Failed opening required '../mws_products.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/update/ranks.php on line 2
当我从浏览器运行文件或进入文件目录并执行文件时,我没有遇到这个问题,例如cd /var/www/update/
排名.php
<?php
require_once('../mws_products.php');
echo "-------------------------------------------------------------\n";
echo date('d-M-Y H:i:s',time())."\n";
echo "Update Ranks\n";
$products->updateRanks();
$database->addUpdate("ranks", time());
echo "\n\n\n";
?>
文件夹结构
[folder] update
|____ [file] ranks.php
[file] mws_products.php
什么可能导致这个问题?(注意:我已经尝试重新启动 apache 和服务器)