I'm using AWS Amazon Web Services and I have 4 identical Web Servers. I have a cron job setup to sent out emails that only needs to run from one server but exists on all 4.
Everything on these web servers is identical which suits me but currently the cron job runs on all 4. I therefore looking for a solution on how to have the job on all 4 servers but only run on one.
I do have a database and thought of using a tmp table to the first to write/register itself in that table would then be the only one to run (the others would read this and then not execute past this point). But I was concerned because they all use an identical system clock and therefore might read the table at the same time and even though one writes to it the others assume they also have access to run.
Would using a table be able to restrict 4 webservers to only 1 contined or would the identical clock factor get in the way?
Note: the server names have the potential of changing with time as they are more like resources then permanent systems. (eg: can spin new ones up when required)...
Is there a better way to do this? Note: I don't want a different server and I want them all identical.
thankyou