弹性beanstalk设置php crontab与cron.yaml

时间:2015-09-30 10:07:43

标签: php amazon-ec2 crontab elastic-beanstalk cron-task

我已阅读弹性beanstalk定期任务手册here, 并在cron.yaml文件中查看此代码之后:

def dir_files_map(start_dir):
    import os
    dd = {}
    # create dictionary where the key is folder root path
    # and the values are the files in that folder
    # filter files based on endswiths(string) clause
    for root, subfolders, filenames in os.walk(start_dir):
        for f in filenames:
            if f.endswith('.b'):
               dd.setdefault(root,[]).append(f)
    return dd

我不确定如何执行以下命令:

version: 1
cron:
 - name: "backup-job"          # required - unique across all entries in this file
   url: "/backup"              # required - does not need to be unique
   schedule: "0 */12 * * *"    # required - does not need to be unique

网址应该是" /var/www/html/myfolder/task.php"或" php /var/www/html/myfolder/task.php"?

1 个答案:

答案 0 :(得分:0)

url值是执行任务时工作者实例上的SQS守护程序将调用的值。在您的情况下,守护程序将连接到localhost并发出以下请求:

POST /backup HTTP/1.1
Host: localhost
User-Agent: aws-sqsd/1.1
Content-Type: application/json
...

here所述。

换句话说,您的脚本应该在执行时运行:

curl -X POST http://localhost/backup
来自工人实例的