apache 如何调试似乎没有运行的 PHP CRON 脚本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2264756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:47:10  来源:igfitidea点击:

How can I debug a PHP CRON script that does not appear to be running?

phpapachecron

提问by account holder

I am trying to setup a CRON job using PHP, but am not having any luck so far.

我正在尝试使用 PHP 设置 CRON 作业,但到目前为止我没有任何运气。

I am following this tutorial: PHP - Create a Cron Job with PHP(dead link)

我正在学习本教程:PHP - Create a Cron Job with PHP(死链接)

I have created the script file with the correct permissions, but the script is not being processed.

我已经使用正确的权限创建了脚本文件,但是没有处理该脚本。

Any ideas?

有任何想法吗?

采纳答案by Blauohr

Little checklist:

小清单:

  1. Is your cron running -> u2ix [checked]
  2. Permissions to use cron [checked]
  3. Does your script run in the shell [checked i hope]
  4. Run a litte script that shows you the environmet in your cron (-> env) / it is neverthe same as in your shell :-)
  5. after execute your php-creat-cronjob-script check with corntab -l the crontab
  1. 您的 cron 是否正在运行 -> u2ix [已检查]
  2. 使用 cron 的权限 [已检查]
  3. 你的脚本是否在 shell 中运行 [检查我希望]
  4. 运行豆蔻脚本,显示你在cron中的environmet( - > ENV)/这是从来没有一样在shell :-)
  5. 在执行您的 php-creat-cronjob-script 检查后,使用corntab -l the crontab

-- do you get mail from your cron ?

- 你从你的 cron 收到邮件吗?

回答by u2ix

Maybe your cron daemon isn't running? The daemon "crond" have to run on startup.

也许你的 cron 守护进程没有运行?守护进程“crond”必须在启动时运行。

Check this with "ps -efc |grep crond"

用“ps -efc |grep crond”检查这个

回答by Philderbeast

it seems you could have any number of issues here.

看来你在这里可能有很多问题。

Firstly have you checked that the file runs successfully from the command line?

首先,您是否检查过该文件是否从命令行成功运行?

if so another simple solution to the problem could be if you didn't set the file to be added correctly in $command so this could be pointing to a file you don't have.

如果是这样,另一个简单的问题解决方案可能是,如果您没有在 $command 中正确设置要添加的文件,那么这可能指向您没有的文件。

Also checking that to cron file you have specified matches the directory referenced in these lines:

还要检查您指定的 cron 文件是否与这些行中引用的目录匹配:

    // this will reinstate your Cron job

    exec("crontab /Users/vin/Sites/site/cron/Feed_cron");