cron 内部如何调度作业?
“现代”cron
守护进程如何在内部安排其作业?一些crond
过去常常通过at
安排运行。那么,在写出 crontab 后, crond: 是否会
- 解析 crontab 以获取所有未来事件以及间隔的睡眠?
- 每分钟轮询一个聚合的 crontab 数据库以确定当前时间是否与计划模式匹配?
- 其他?
谢谢,
How do "modern" cron
daemons internally schedule their jobs? Some crond
s used to schedule a run every so often via at
. So after a crontab is written out, does crond
:
- Parse the crontab for all future events and the sleep for the intervals?
- Poll an aggregated crontab database every minute to determine if the current time matches the schedule pattern?
- Other?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几只蟋蟀听到了这个问题。很好的 RTFC,带有一些离散事件模拟论文和维基百科:
http://en.wikipedia。 org/wiki/Cron#Multi-user_capability
A few crickets heard in this question. Good 'ol RTFC with some discrete event simulation papers and Wikipedia:
http://en.wikipedia.org/wiki/Cron#Multi-user_capability
我写了一篇博客文章描述它。< br>
其中包含关于如何实现任务调度实用程序的我的想法,例如 Cron或 Quartz。
引用那里的相关文本:
job.nextExecutionTime( 优先级) 优先的
。PriorityBlockingQueue
(线程安全堆)中选取所有任务来执行它们)我们称之为QueueConsumerThread:
请注意,这可能不是 cron 的内部实现方式。
不过,这是我能想到的最优化的解决方案。
它不需要轮询,并且所有线程都会休眠,直到需要执行任何工作为止。
I wrote a blog post describing it.
which contains my thoughts on how to implement task scheduling utilities like Cron or Quartz.
Quoting the relevant text from there:
PriorityBlockingQueue
(thread-safe heap) prioritized onjob.nextExecutionTime()
.Lets call it QueueConsumerThread:
Note that this might not be how cron is implemented internally.
However, this is the most optimal solution that I can think of.
It requires no polling and all threads sleep until they need to do any work.