I have two web servers. Server 'A' and server 'B'. Both are exact duplicate of the other and are connected to a load-balancer for serving clients.
I have a tasks (cronjob) that is executed at every hour, every day. This task is currently running only on server 'A'. The problem is that this tasks is really important and if server 'A' crash for some reason the task will no longer run.
I would like server 'B' to execute the task but only if server 'A' didn't. Both tasks are PHP scripts interacting with a MySQL database.
I'm thinking about using some rows in a table (using MySQL locks?) as a flag for the server 'B' to start his task if server 'A' didn't do it and vice versa.
Please note that the task file on both servers must be exactly the same.
Thank you.