编辑:
我得到这个cron 406错误页面!
这里是crontab(从cPanel复制):
* * * * * GET https://abc.com/cron/sendBulletinEmails.php >> /home/abc/public_html/cron/logs/sendBulletinEmails.log
这里是日志:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>406 Not Acceptable</title> </head><body> <h1>Not Acceptable</h1> <p>An appropriate representation of the requested resource /cron/sendSurveyEmails.php could not be found on this server.</p> <p>Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.</p> </body></html>
这里是我的crontab:
* * * * * { cd /var/www/cron && /usr/bin/php -f sendQueuedEmails.php ;} | /usr/bin/logger -t sendQueuedEmails
我正在运行Ubuntu的。
我没有看到任何日志:
/var/log/cron /var/log/messages /var/mysql/log
它在哪里?
grep“CRON”/ var / log / syslog
应该注意的是,A)你没有redirect标准错误。 所以如果你的脚本在轰炸,错误不会导致消息文件。 所以在pipe道前放一个2>&1 。 B)Cron没有对环境variables进行深究。 你确定你的PHP脚本实际上工作吗? 有一个很好的机会,这就是为什么没有输出。 尝试在你的login脚本中find如下所示: . /home/user/.bashrc . /home/user/.bashrc
– 克里斯托弗·卡雷尔
它没有logging任何东西。 在我的cron中使用GET(感谢这个答案 )之后,我将输出追加到日志文件,如下所示:
* * * * * GET http://localhost/cron/sendQueuedEmails.php >> /var/www/cron/logs/sendQueuedEmails.log