php - CRON 无法在 Amazon EC2 中运行?

标签 php linux amazon-web-services amazon-ec2 cron

另一篇文章描述了一种测试 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 的文档似乎已经有好几年了。提前致谢。

引用:

Setting Up Cron in Amazon Linux AMI

最佳答案

你检查过 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/

相关文章:

php - 在 if else 语句中从不同查询中选择一个数据

php - 我一直收到 "You have an error in your SQL syntax",如果直接运行,SQL 会工作

php - 如何从 mysql 数据库中回显第 1...n 列,除了 php 中的第一个列?

php - 无法在 Ubuntu Linux 上安装 libcurl PHP

linux - 如何传递函数路径

node.js - aws + serverless + webpack => 在产品中找不到模块 xxx

php - 在两 (2) 个日期之间,列的日期格式为 (Y-m-d)

linux - 在树莓派 2 上运行 wakaama DM 服务器时发生套接字错误

amazon-web-services - 如何使用 S3 和 Cloudfront 对单个域进行 301 重定向(HTTP 到 HTTPS)&&(www 到非 www)?

amazon-web-services - 如何将 docker 容器镜像更新从 AWS ECR 部署到 ECS?