On 13/07/20 2:07 am, Uoti Urpala wrote:
On Sun, 2020-07-12 at 17:13 +0300, Andrei Borzenkov wrote:
12.07.2020 16:21, Amish пишет:
I have a timer file like this:
[Unit]
Description=Foo
After=multi-user.target
[Timer]
OnCalendar=*:0/5
Persistent=false
[Install]
WantedBy=timers.target
Because AFAIK timers.target runs before multi-user.target. But here
something inside timers.target waits for multi-user.target.
So how does systemd resolve this loop?
There is no loop. There is no transitive dependency between timer unit
and service unit. Timer unit gets started early and enqueues start job
for service unit; this start job waits for multi-user.target according
to After dependency. Mulitple invocation of timer will try enqueue start
job again which will simply be merged with existing pending request.
But shouldn't the After line be in the .service file, not the timer, in
this case? The timer should be ready early if it's activated by
timers.target, the service should wait before running.
I have put it in .timer file and works as expected.
Jul 13 10:38:27 server1 systemd[1]: Reached target Multi-User System.
Jul 13 10:38:27 server1 systemd[1]: Started Foo. (the timer activated)
Jul 13 10:38:27 server1 systemd[1]: Reached target Timers.
...
Jul 13 10:40:01 server1 systemd[1]: Starting Foo... (the service that
runs at */5)
Jul 13 10:40:01 server1 systemd[1]: foo.service: Succeeded.
Jul 13 10:40:01 server1 systemd[1]: Finished Foo.
Regards
Amish
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel