cron如何在内部安排工作? [英] How does cron internally schedule jobs?
本文介绍了cron如何在内部安排工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现代" cron
守护程序如何在内部 安排其工作?有些crond
经常通过at
安排运行时间.因此,在写出crontab之后,crond
:
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
:
- 解析crontab以获得所有将来的事件以及间隔的睡眠吗?
- 每分钟轮询一个汇总的crontab数据库以确定当前时间是否与计划模式匹配?
- 其他?
谢谢
推荐答案
在此问题中听到了一些声.不错的RTFC,其中包含一些离散事件模拟论文和Wikipedia:
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
此cron使用的算法为 如下:
The algorithm used by this cron is as follows:
- 启动时,在以下目录的主目录中查找名为.crontab的文件 所有帐户持有人.
- 对于找到的每个crontab文件,确定将来的下一次 每个命令都将运行.
- 将这些命令及其命令放到Franta-Maly事件列表中 对应的时间和他们的五个 字段"的时间说明符.
- 进入主循环:
- On start-up, look for a file named .crontab in the home directories of all account holders.
- For each crontab file found, determine the next time in the future that each command is to be run.
- Place those commands on the Franta-Maly event list with their corresponding time and their "five field" time specifier.
- Enter main loop:
- 检查队列开头的任务条目,计算在 将来将要运行.
- 睡眠一段时间.
- 在唤醒时并确认正确的时间后,在以下位置执行任务 队列的头(在后台) 拥有用户特权的人 创建了它.
- 确定将来的下一次运行此命令并放置 再次将其放回事件列表中
- Examine the task entry at the head of the queue, compute how far in the future it is to be run.
- Sleep for that period of time.
- On awakening and after verifying the correct time, execute the task at the head of the queue (in background) with the privileges of the user who created it.
- Determine the next time in the future to run this command and place it back on the event list at that time
这篇关于cron如何在内部安排工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文