另一篇文章描述了一种测试 cron 是否正在运行的方法是使用此脚本创建一个 crontab -e:
* * * * * /usr/bin/uptime > /tmp/uptime
当我去检查 cron cat/tmp/uptime 时没有结果。具有 php 直接路径的测试脚本也是如此。
我正在运行运行 Amazon Linux 的 AWS。
我用 chkconfig --list crond 检查了 cron 是否在运行 结果:
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
更新(基于评论)
[ec2-user@ip-xxx-xxx ~]$ service crond status
crond (pid 2844) is running...
[ec2-user@ip-xxx-xxx ~]$ ps aux | grep crond
root 2844 0.0 0.2 121636 2572 ? Ss Sep04 0:01 crond
ec2-user 7904 0.0 0.2 110468 2096 pts/0 S+ 22:46 0:00 grep --color=auto crond
为了安全起见,我使用以下命令手动启动了 cron:
sudo service crond start
我还尝试了 sudo su 并在 ec2-user 和 root 中创建了实例。似乎没有什么能真正运行 cron。
有人有什么建议吗?其他地方关于 Cron 的文档似乎已经有好几年了。提前致谢。
引用:
最佳答案
你检查过 cron 守护进程的状态吗?
$ service crond status
crond (pid xxx) is running...
$ ps aux | grep crond
root 2533 0.0 0.1 119552 1784 ? Ss Apr04 1:57 crond
ec2-user 22203 0.0 0.2 110460 2084 pts/0 S+ 09:37 0:00 grep --color=auto crond
然后,如果 cron 守护进程似乎没有运行,您可以启动它
$ service crond start
关于php - CRON 无法在 Amazon EC2 中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46193801/