Hi,

the most idiomatic approach is likely to use the new concurrency limits for
slices which will be release with the upcoming v258:
https://www.freedesktop.org/software/systemd/man/devel/systemd.slice.html#ConcurrencyHardMax=

Otherwise if the set of templated units is fixed and the order is arbitrary
anyhow, you could declare one to start a few seconds later and add an
After= ordering on the other timer. Systemd will then postpone starting the
service while the other one is still activating (which for oneshot services
means they are still executing).

Cheers, Nils

On Tue, Jul 29, 2025, 12:00 Marc Haber <mh+systemd-de...@zugschlus.de>
wrote:

> Hi,
>
> I have a template service unit which runs a oneshot service that
> generates both high CPU and high I/O load for a couple of minutes. The
> service is templated a couple of times and runs from an, also templated
> timer.
>
> In another use case, I have independent services that generate high CPU
> and high I/O.
>
> In both cases, it has been measured that total processing time is
> quicker when one lets the jobs run one after the other instead of having
> them conurrently compete over same set of resources. The measurement
> results are even more clear when the data is stored on HDDs due to head
> movement and disk rotation latency.
>
> I would like to lock them against each other that only one of those
> services runs concurrently at a time, and other instances that might
> have been requested while one is still running are delayed until
> everyhing is "free". Missing a job because one other is already running
> would be a bug.
>
> The solution one finds on the net is to use flock(1) in the ExecStart*
> options, often making wrapper scripts necessary. I find this clumsy and
> un-systemd-like and would not like to do that.
>
> Does systemd offer a better solution for this?
>
> Greetings
> Marc
>
> --
>
> -----------------------------------------------------------------------------
> Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
> Leimen, Germany    |  lose things."    Winona Ryder | Fon: *49 6224 1600402
> Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421
>

Reply via email to