[systemd-devel] Can service of timers.target having After=multi-user.target create a loop?

Uoti Urpala uoti.urpala at pp1.inet.fi
Sun Jul 12 20:37:56 UTC 2020


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.




More information about the systemd-devel mailing list