在 cron 作业已经运行时停止其启动(甚至跨服务器)
我不认为这与其他问题完全相同,但如果已经得到解答,请随时指出我的某个地方。
我正在寻找一种方法,让 cron 作业仅在尚未运行时才开始运行。例如,如果某个作业每 15 分钟运行一次,但有时需要一个小时才能运行,我不希望启动重复的进程并与原始作业正在执行的操作重叠。
在其他问题中,其他人讨论过制作一个 pid 文件来阻止作业启动重复项(或类似的策略),但我的情况有点不同。我有多台运行 cron 作业的计算机,并且我希望其中任何一台计算机上当前正在运行的进程能够阻止该作业的新实例启动。所以 pid 文件是不够的,因为它是一台机器的本地文件。
处理这种情况的最佳方法是什么?
I don't think this is an exact duplicate of other questions, but feel free to point me somewhere if it's already been answered.
I'm looking for a way to have a cron job only start running if it isn't already running. For example, if a job runs every 15 minutes but occasionally takes an hour to run, I don't want duplicate processes to start and overlap what the original job is doing.
In other questions others have talked about making a pid file that stops the job from starting duplicates (or similar strategies), but my case is a little different. I have multiple machines that run cron jobs, and I want a currently-running process on any of them to stop new instances of that job from starting. So a pid file wouldn't be enough, since it would be local to the one machine.
What is the best way of dealing with this situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
共享文件夹上的 PID 文件?
A PID file over a shared folder?