【发布时间】:2016-09-14 13:22:10
【问题描述】:
我基本上想要做的是定期在我的服务器层 Web 应用程序中运行 PHP 脚本。为此,我创建了一个 Worker Tier 应用程序并将以下代码添加到 cron.yaml 中,如 Running cron jobs on Amazon Web Services (AWS) Elastic Beanstalk 中所述。
version: 1
cron:
- name: "email-job" # required - unique across all entries in this file
url: "https://www.example.com/cron_test.php" # required - does not need to be unique
schedule: "* */10 * * *" # required - does not need to be unique
根据脚本,cron_test.php 会每 10 分钟向我发送一封电子邮件(cron_test.php 没有任何问题,因为它可以在我的浏览器中完美运行)。
由于这不起作用,我尝试将 url 更改为本地的。
version: 1
cron:
- name: "email-job" # required - unique across all entries in this file
url: "/send_mails.php" # required - does not need to be unique
schedule: "* */10 * * *" # required - does not need to be unique
在send_email.php 页面中,我像这样简单地重定向到服务器层中所需的网址。
header("Location: https://www.example.com/cron_test.php");
奇怪的是,我仍然没有收到来自我的服务器层应用程序的任何电子邮件。当我检查我的日志时,我可以看到以下内容
127.0.0.1 (-) - - [18/May/2016:04:58:59 +0000] "POST /send_email.php HTTP/1.1" 302 - "-" "aws-sqsd/2.3"
虽然 302 表明确实发生了重定向,但我仍然没有收到任何电子邮件。我究竟做错了什么?还有其他方法可以实现我的目标吗?
【问题讨论】:
标签: php amazon-web-services cron