YBathia
YBathia

Reputation: 902

How can I ensure cron job runs only on one host at any time

I have a django management command run as a cron job and it is set on multiple hosts to run at the same time. What is the best way to ensure that cron job runs on only one host at any time? One approach is to use db locks as the cron job updates a MySQL db but I am sure there are better(django or pythonic) approaches to achieve what I am looking for

Upvotes: 0

Views: 705

Answers (1)

Trurl McByte
Trurl McByte

Reputation: 1

simple way: - start cron before need time (for example two minutes) - force synchronize time (using ntp or ntpdate) (optional paranoid mode) - wait till expected time, run job

Upvotes: -1

Related Questions