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
:
“现代”守护进程如何在内部安排他们的工作?一些cronds经常通过at计划一次跑步。crontab写完后,crond:
- Parse the crontab for all future events and the sleep for the intervals?
- 为所有未来事件解析crontab,为间隔解析睡眠?
- Poll an aggregated crontab database every minute to determine if the current time matches the schedule pattern?
- 每分钟轮询聚合的crontab数据库,以确定当前时间是否与计划模式匹配?
- Other?
- 其他的吗?
Thanks,
谢谢,
1 个解决方案
#1
47
A few crickets heard in this question. Good 'ol RTFC with some discrete event simulation papers and Wikipedia:
在这个问题中听到了一些蟋蟀的叫声。好'ol RTFC与一些离散事件模拟文件和*:
http://en.wikipedia.org/wiki/Cron#Multi-user_capability
http://en.wikipedia.org/wiki/Cron Multi-user_capability
The algorithm used by this cron is as follows:
该cron使用的算法如下:
- On start-up, look for a file named .crontab in the home directories of all account holders.
- 在启动时,在所有帐户持有人的主目录中查找名为.crontab的文件。
- For each crontab file found, determine the next time in the future that each command is to be run.
- 对于找到的每个crontab文件,确定在未来的任何时候运行每个命令。
- Place those commands on the Franta-Maly event list with their corresponding time and their "five field" time specifier.
- 将这些命令放在Franta-Maly事件列表中,并使用相应的时间和“五个字段”时间说明符。
- 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
- 确定下一次运行该命令并将其返回到事件列表的下一次时间。
- 输入主循环:检查队列头部的任务条目,计算它在未来运行的距离。睡上一段时间。在唤醒和验证正确的时间之后,以创建任务的用户的特权在队列的前端(后台)执行任务。确定下一次运行该命令并将其返回到事件列表的下一次时间。
#1
47
A few crickets heard in this question. Good 'ol RTFC with some discrete event simulation papers and Wikipedia:
在这个问题中听到了一些蟋蟀的叫声。好'ol RTFC与一些离散事件模拟文件和*:
http://en.wikipedia.org/wiki/Cron#Multi-user_capability
http://en.wikipedia.org/wiki/Cron Multi-user_capability
The algorithm used by this cron is as follows:
该cron使用的算法如下:
- On start-up, look for a file named .crontab in the home directories of all account holders.
- 在启动时,在所有帐户持有人的主目录中查找名为.crontab的文件。
- For each crontab file found, determine the next time in the future that each command is to be run.
- 对于找到的每个crontab文件,确定在未来的任何时候运行每个命令。
- Place those commands on the Franta-Maly event list with their corresponding time and their "five field" time specifier.
- 将这些命令放在Franta-Maly事件列表中,并使用相应的时间和“五个字段”时间说明符。
- 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
- 确定下一次运行该命令并将其返回到事件列表的下一次时间。
- 输入主循环:检查队列头部的任务条目,计算它在未来运行的距离。睡上一段时间。在唤醒和验证正确的时间之后,以创建任务的用户的特权在队列的前端(后台)执行任务。确定下一次运行该命令并将其返回到事件列表的下一次时间。