E
E
entermix2016-11-09 23:10:23
linux
entermix, 2016-11-09 23:10:23

How to distribute CRON tasks?

Let's say there are several servers where database replication and file synchronization are configured.
It is necessary to perform certain tasks on a schedule, for example, server No. 1 crashes, the ns record with a new IP for the domain (server No. 2) automatically changes, but what about the tasks? Those. so that they are guaranteed not to be executed simultaneously on different servers.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mika Slepinin, 2016-11-10
@mikalaikaia

Look towards Ansible. You can create an inventory file with different servers, or even with groups of servers, use different roles for them. Let your cron run a playbook once a minute, or even a simple bash script that pings the servers and, if there is no response, performs the necessary tasks. With Ansible, you can do this on multiple machines at once.

V
Vladimir, 2016-11-10
@MechanID

This means that when cron starts tasks on each of the servers, it first checks whether this is the main server, and then, based on the results of the check, the task starts or does not start, for example, if your DNS record changes, then the servers can compare whether the domain is resolving to the ip of this server , yes - we start tasks, no - we skip tasks.
This can be easily implemented in bash.

T
T_y_l_e_r, 2016-11-10
@T_y_l_e_r

I would write a "bicycle" and make a separate server for it that does not fall, it seems to be the simplest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question