[systemd-devel] run only a single service at a time

Andrei Borzenkov arvidjaar at gmail.com
Fri Oct 29 05:47:19 UTC 2021


On 28.10.2021 16:04, Olaf Hering wrote:
> There is A.timer and its A.service, and B.timer and B.service.
> Both A and B do not know about each other per default.
> Both timers fire in their own cadence.
> Both services have their unpredictable time until they finish.
> So it may happen that A.service is started while B.service is still active.
> 
> But, unfortunately both services may touch the same files while they run.
> 
> Does systemd have a way to serialize execution of such units, so that starting of A.service is delayed until B.service is done, and via versa?
> 

Not that I am aware of. Similar questions (or requests) came up in the past.

> Before=/After= may not apply, at least the docs say nothing about timer driven units.
> 

It has nothing to do with timer. After/Before are only effective if both
start jobs are queued for execution. If one unit is already started,
then After/Before becomes noop. If A has "After: B" and B has "After: A"
and both are attempted to be started, it is a loop and systemd will drop
one of conditions.

How start of these units is triggered is irrelevant.

> 
> I might be able to add some locking to A.service and B.service with some creative ExecStartPre/Post= in A.service.d/lock.conf ...
> 
> 
> Olaf
> 



More information about the systemd-devel mailing list