linux - cron 如何在内部安排作业?

“现代”cron 守护进程如何在内部 安排他们的工作?一些 crond 用于通过 at 每隔一段时间安排一次运行。因此,在写出 crontab 后,crond:

  1. 解析所有 future 事件的 crontab 和间隔的 sleep ?
  2. 每分钟轮询一次聚合的 crontab 数据库以确定当前时间是否与计划模式匹配?
  3. 其他?

谢谢,

最佳答案

在这个问题中听到了一些蟋蟀。不错的 RTFC,带有一些离散事件模拟论文和维基百科:

http://en.wikipedia.org/wiki/Cron#Multi-user_capability

The algorithm used by this cron is as follows:

  1. On start-up, look for a file named .crontab in the home directories of all account holders.
  2. For each crontab file found, determine the next time in the future that each command is to be run.
  3. Place those commands on the Franta-Maly event list with their corresponding time and their "five field" time specifier.
  4. Enter main loop:
    1. Examine the task entry at the head of the queue, compute how far in the future it is to be run.
    2. Sleep for that period of time.
    3. 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.
    4. Determine the next time in the future to run this command and place it back on the event list at that time

https://stackoverflow.com/questions/3982957/

相关文章:

linux - 需要对 Linux bash 内置 exec 命令行为的解释

linux - qstat 和长作业名称

python - 带有隐藏窗口的跨平台子进程

linux - 应用程序如何在运行时解析为不同版本的共享库?

linux - 在家学习内核黑客和嵌入式开发?

c - 为什么在 Linux 中使用 select

linux - RealUID,保存的 UID,有效的 UID。这是怎么回事?

linux - 跨多台计算机管理用户配置文件

c - Linux内核代码中的 "EXPORT_SYMBOL"是什么意思?

linux - 使用 Linux 加载程序时 ldconfig 错误 :"is not a symb