“现代”cron
守护进程如何在内部 安排他们的工作?一些 crond
用于通过 at
每隔一段时间安排一次运行。因此,在写出 crontab 后,crond
:
- 解析所有 future 事件的 crontab 和间隔的 sleep ?
- 每分钟轮询一次聚合的 crontab 数据库以确定当前时间是否与计划模式匹配?
- 其他?
谢谢,
最佳答案
在这个问题中听到了一些蟋蟀。不错的 RTFC,带有一些离散事件模拟论文和维基百科:
http://en.wikipedia.org/wiki/Cron#Multi-user_capability
The algorithm used by this cron is as follows:
- 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
关于linux - cron 如何在内部安排作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3982957/