简体   繁体   English

PHP脚本未从cron运行

[英]PHP script not running from cron

I have the following command: 我有以下命令:

php /var/www/html/XYZ/api_new/XYZ-API/src/public/fetch_events/fetch_events.php

This runs perfectly from the command line. 从命令行可以完美运行。 However, I want it to run as a cron job every 15 mins, so I added the following entry to my crontab: 但是,我希望它每15分钟作为cron作业运行一次,因此我在crontab中添加了以下条目:

15 * * * * php /var/www/html/XYZ/api_new/XYZ-API/src/public/fetch_events/fetch_events.php

This however, does not seem to work at all. 但是,这似乎根本不起作用。 It does not even show up in my system logs (all my other cron jobs do show up). 它甚至没有显示在我的系统日志中(我的所有其他cron作业都显示了)。

Any ideas? 有任何想法吗?

There's not really enough information to answer your question, but here are some things that might help. 确实没有足够的信息来回答您的问题,但是这里有些事情可能会有所帮助。

Sometimes cronjobs don't have context for where to find these programs, so do which php and replace the full path with the php command. 有时,cronjobs没有可在何处找到这些程序的上下文,因此使用which php并用php命令替换完整路径。

/var/log/cron should have a record of it running, but if there's a problem, you might not know why. / var / log / cron 应该有运行记录,但是,如果有问题,您可能不知道为什么。 Try appending the following to the end of the cron line to aid in debuging: 尝试将以下内容附加到cron行的末尾以帮助调试:

>> /tmp/fetch_events.log 2>&1

This file will probably contain some hints as to what's going on when the cron does fire. 这个文件可能会包含一些提示,以什么回事时的cron 火。

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

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