首页 > 解决方案 > How to run wget cron command on elastic beanstalk config

问题描述

I have one instance on elastic Beanstalk. According to the documentation for running the cron on beanstalk environment I would create a file named something like "mycron.config" and place it in the .ebextensions folder.

I've done that. The "mycron.config" file read like this:

commands:
     command: "*/5 * * * * /usr/bin/wget -O /dev/null https://example.com/pull-shopify-orders"

I'm attempting to hit this url every 5 minutes. The cron isn't running. What am I doing wrong?

标签: amazon-web-servicescronamazon-elastic-beanstalk

解决方案


Not sure what documentation you are referring to (no link), but I guess you write about cron.yaml which is only for worker environments.

To setup cron on web environments, you have to create /etc/cron.d/mycron "manually" with proper content and permissions.

This procedure is explained in a very recent AWS blog post:

The blog creates cron-linux.config with the exemplary content of (modified content for your use-case):

files:
    "/etc/cron.d/mycron":
        mode: "000644"
        owner: root
        group: root
        content: |
            */5 * * * * root /usr/local/bin/myscript.sh

    "/usr/local/bin/myscript.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
            #!/bin/bash

            #date > /tmp/date
            /usr/bin/wget -O /dev/null https://example.com/pull-shopify-orders
            exit 0

commands:
    remove_old_cron:
        command: "rm -f /etc/cron.d/mycron.bak"

推荐阅读