简体   繁体   English

如何确保cron作业在任何时间仅在一台主机上运行

[英]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. 我有一个django管理命令作为cron作业运行,并且在多个主机上设置为同时运行。 What is the best way to ensure that cron job runs on only one host at any time? 确保cron作业随时仅在一个主机上运行的最佳方法是什么? 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 一种方法是在cron作业更新MySQL数据库时使用db锁,但我确信有更好的(django或pythonic)方法来实现我想要的功能

简单方法:-在需要的时间(例如两分钟)之前启动cron-强制同步时间(使用ntp或ntpdate)(可选的偏执模式)-等待预期时间,运行作业

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确保一次仅运行一个线程,最新的数据? - How to ensure only one thread runs at a time, the most recent data? 我怎么能解决这个cron工作? - How else can I troubleshoot this cron job? 确保变量在任何给定时间仅处于一种状态 - Ensure a variable is only at one state at any given time Python tkinter:如何确保在单击时仅创建一个子窗口,而不在每次单击按钮时创建一个新窗口? - Python tkinter: How can I ensure only ONE child window is created onclick and not a new window every time the button is clicked? 如果我的gpio引脚为高电平,如何才能执行仅执行的cron作业? - How can I make a cron job that would only execute if my gpio pin is HIGH? 如何确保Celery任务以正确的设置运行? - How can I ensure a Celery task runs with the right settings? Python中如何保证一段代码一次只能被一个请求执行? - How to ensure that a block of code can be executed only by one request at a time in Python? 复选框验证:如何确保用户只能勾选一个复选框? - Checkbox validation: how do i ensure user can only tick one box only? 如何确保一个特定任务或其余任务可以使用 asyncio 一次运行? - How can I ensure either one specific task, or the rest, can run at a time with asyncio? 如何检查以cron作业开头的脚本是否完成? - How can I check whether the script started with cron job is completed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM