在aws工作环境中设置cron作业

时间:2017-10-27 21:44:11

标签: php amazon-web-services cron

我有两个php文件regular.php& regular_with_argument.php 在cli上我只需输入以下命令来运行这些文件:

php regular.php
php regular_with_argument.php 1 (1 is the argument/parameter i pass)

我想在我的aws弹性beanstalk工作环境中设置cron.yaml。 所以我按照如何设置crontab的说明进行操作,这就是我得到的:

version: 1
cron:
- name: "Regular Report"
url: "/regular.php"
schedule: "45 4 * * *"
- name: "Regular With Argument Report"
url: "/regular_with_argument.php 1"
schedule: "20 4 4 * *"

我的问题是,带参数的那个不起作用。我在这里错过了什么吗?错误是

错误:[实例:i-0f20de5f1a4933d5b]实例上的命令失败。返回码:1输出:解析文件'cron.yaml'失败,原因是:坏URI(不是URI?):/ php regular_with_argument.php 1 - (AWS :: EB :: SQSD :: ScheduleParser :: ScheduleFileError)。 挂钩/opt/elasticbeanstalk/addons/sqsd/hooks/start/02-start-sqsd.sh失败。有关更多详细信息,请使用控制台或EB CLI检查/var/log/eb-activity.log。

1 个答案:

答案 0 :(得分:0)

我认为唯一的方法是让你的PHP解析$ _GET [' some_arg']作为参数,然后在你的cron.yaml中,将url设置为:

url: "/regular_with_argument.php?some_arg=1"