СRON how to distribute tasks?

Let's say there are some servers where configured with database replication, synchronize files.

Need to perform some task on schedule, for example, the server No. 1 falls, and automatically changes the ns record with the new IP for a domain (server No. 2), but what about the tasks? That is, that they guaranteed would not run simultaneously on different servers.
July 2nd 19 at 18:06
4 answers
July 2nd 19 at 18:08
keepalived, ucarp is not considered?
only the server needs to be on the same network, don't know how it sounds scientific, so to speak have to look at a single gateway.
Servers can even be in different data centers, otherwise, why such distribution is needed :) - nicklaus.Will commented on July 2nd 19 at 18:11
One of the most right advice. Spacing for different DTS no problem - will require tunnel for service traffic of the specified protocols. Triggering of the switch will be the signal to start the task chart. - Jensen.Rosenbaum commented on July 2nd 19 at 18:14
July 2nd 19 at 18:10
Look at Ansible. You can create an inventory file from different servers, or server groups, use applied to them different roles. Let you have a cron runs every minute playbook, or even a simple bash script that pings the server, and in the absence of a response to perform the necessary tasks. In the case of Ansible, you can do it on multiple machines at once.
Perhaps You do not quite understand the question, there are permanent tasks (e.g. cancellation fee), they need to be run only on the server that at the moment main. i.e. not to allow the execution on multiple servers simultaneously.

But You gave me an idea, you can ping the domain to check his IP and if it matches the current server to allow script execution. - nicklaus.Will commented on July 2nd 19 at 18:13
July 2nd 19 at 18:12
So you need to when you run the Kron task on each server was check first and main it is the server, then the scan task run or not run, for example if you have changed a DNS record that the server can compare and brezovitsa is domain in IP of this server, Yes - running task, no - skypem tasks.
It's easy enough you can implement in bash.
July 2nd 19 at 18:14
I would "bike" was written and it would separate the server is made which does not fall, it seems the most simple.
"Separate server which is not falling" is like? - nicklaus.Will commented on July 2nd 19 at 18:17

Find more questions by tags Distributed computingCentOSCronLinux