8

How to run some service exactly every second? Overlapping allowed.

Here is my timer unit for systemd:

[Unit]
Description=Send jobs every second

[Timer]
OnBootSec=1min
OnUnitActiveSec=1s
Unit=app.jobs-send.service

[Install]
WantedBy=multi-user.target

But app.jobs-send.service service doesn't executed every second:

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.

There is a gap about 17:57:58 - 17:57:48 = 10 seconds.

How to exec task every second?

Anton Medvedev
  • 3,393
  • 3
  • 28
  • 40

1 Answers1

6

As documented in man systemd.time, the accuracy of OnUnitActiveSec= is subject to the AccuracySec= setting, also documented there. Set to AccuracySec=1us for best resolution.

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49