简体   繁体   English

为什么我的Cron工作无法运行?

[英]Why is my cron job not running?

I am trying to run a cron job at 5:20pm as below but it's not working. 我正在尝试在下午5:20进行cron作业,如下所示,但它不起作用。

20 17 * * 1 /usr/bin/php /home/myacc/public_html/job/generate.php

I basically did crontab -e and entered the above line there and saved the file. 我基本上做了crontab -e并在那里输入了上面的行并保存了文件。

If I try running the command directly from the command line as below, it works fine: 如果我尝试直接从命令行运行命令,如下所示,它将正常工作:

php /home/myacc/public_html/job/generate.php

What am I doing wrong? 我究竟做错了什么?

Also, how do I send a message from the cron to either a log file or email so that I know what's going on? 另外,如何将cron的消息发送到日志文件或电子邮件,以使我知道发生了什么?

You can record all the logs of your cronjobs by installing postfix and configuring it as local domain during installation. 您可以通过安装postfix并将其配置为本地域来记录cronjobs的所有日志。 Such that you can see the logs of your cron jobs by vi /var/mail/<user-name> . 这样,您可以通过vi /var/mail/<user-name>来查看cron作业的日志。 Try looking the logs and figure out the problem. 尝试查看日志并找出问题所在。 If you don't find any solution post the log so that it will help others to diagnose the problem. 如果找不到任何解决方案,请在日志中发布日志,以帮助其他人诊断问题。 I'm adding this as an answer instead of comment because i think I'm answering your second query. 我将其添加为答案而不是评论,因为我想我正在回答您的第二个查询。

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

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