Running a cron job in Elastic Beanstalk
<p>So I have a functionality in a Django Elastic Beanstalk app that works like so:</p>

<ul>
<li>Download a file</li>
<li>Parse the file, run some calls to API's with the data from the file</li>
<li>Update the database of the EB instance with the new data</li>
</ul>

<p>In testing instances where I just set up a local cron job. I just called <code>wget</code> on a specific URL of my Django application and it will run the command.</p>

<p>My problem is how to handle this in a multi-instanced Elastic Beanstalk application. Only one instance of my EB application should run this command. I want to avoid race conditions on the database and redundant calls to external API's from multiple instances. i.e. only one instance should be writing to the databe.</p>

<p>However, Googling around shows setting up cron jobs is awkward, particularly if your new to EB like I am. The most promising sounding method seems to be the <code>cron.yaml</code> method, but there does not seem to be an example of setting up a cron worker environment anywhere on the web from what I can see.</p>

<p>My understanding is:</p>

<ul>
<li>You include a cron.yaml file in the root of your EB project.</li>
<li>Deploy the project</li>
<li>The cron jobs are automatically set up in a worker environment (?).</li>
<li>The command you defined is ran at the specified time(s).</li>
</ul>

<p>My question is how do you make sure that only one instance will run this command? Do I have the right idea on how <code>cron.yaml</code> works or is there something I'm missing</p>