Issue
I'm trying to run a wget command every minute that simply hits a url. I currently have the following in a file called project.config in the .ebextensions folder:
01_test_cron: command: * * * * * /usr/bin/wget -O /dev/null http://name.of.url
It currently does not execute - are there any glaring errors?
Solution
Since, Elastic Beanstalk instances auto-scale, you need to consider a few things. Does the cron run on every instance as its setup or just the leader instance? For the second option, here are the contents you should have in your project.config
file:
container_commands:
01_remove_old_cron_jobs:
command: "crontab -r || exit 0"
02_cronjobs:
command: "cat .ebextensions/crontab | crontab"
leader_only: true
The contents of the .ebextensions/crontab
file would be:
* * * * * /usr/bin/wget -O /dev/null http://name.of.url
Updated on March 9, 2015
You will also need to add a blank line at the end of the project.config
file as per the YAML syntax.
Answered By - Noman Ur Rehman Answer Checked By - Marie Seifert (WPSolving Admin)