如何每秒运行一些服务?允许重叠。
这是我的systemd的计时器单元:
[Unit]
Description=Send jobs every second
[Timer]
OnBootSec=1min
OnUnitActiveSec=1s
Unit=app.jobs-send.service
[Install]
WantedBy=multi-user.target
但app.jobs-send.service
服务不会每秒执行一次:
May 07 17:57:38 app.deployer.org systemd[1]: Started Send jobs to queue.
May 07 17:57:48 app.deployer.org systemd[1]: Starting Send jobs to queue...
May 07 17:57:48 app.deployer.org systemd[1]: Started Send jobs to queue.
May 07 17:57:58 app.deployer.org systemd[1]: Starting Send jobs to queue...
May 07 17:57:58 app.deployer.org systemd[1]: Started Send jobs to queue.
May 07 17:58:08 app.deployer.org systemd[1]: Starting Send jobs to queue...
May 07 17:58:08 app.deployer.org systemd[1]: Started Send jobs to queue.
17:57:58 - 17:57:48 = 10秒之间存在差距。
如何每秒执行一次任务?
答案 0 :(得分:1)
正如man systemd.time中所述,OnUnitActiveSec=
的准确性受AccuracySec=
设置的约束,并在此处进行了记录。设置为AccuracySec=1us
以获得最佳分辨率。