Discussion:
Cascading oneshot units
(too old to reply)
Evan Klitzke
2018-03-20 06:44:50 UTC
Permalink
Raw Message
I am wondering how to create a cascade of oneshot units that should run
on a timer. What I'm imagining is something like the following:

foo.timer
foo.service
bar.service

In this example foo.service and bar.service are both Type=oneshot with
no [Install] section. foo.timer declares Unit=foo.service, which causes
foo.service to run whenever the timer triggers. That's simple enough,
and I have that working.

I want bar.service to run after foo.service completes, as it operates on
some data generated by foo.service. I'm not sure what the magic bits are
to make this work. I could obviously work around the issue by wrapping
the logic for the two jobs in a shell script that runs the two actions
sequentially, but I rather like the logging and status utilities
provided by systemd, so having them as separate units seems preferable.

--
Evan Klitzke
https://eklitzke.org/
Andrei Borzenkov
2018-03-20 07:15:14 UTC
Permalink
Raw Message
The simplest way is to add Wants=bar.service and After=bar.service to foo.service.

Отправлено с iPhone

> 20 марта 2018 г., в 7:44, Evan Klitzke <***@eklitzke.org> написал(а):
>
> I am wondering how to create a cascade of oneshot units that should run
> on a timer. What I'm imagining is something like the following:
>
> foo.timer
> foo.service
> bar.service
>
> In this example foo.service and bar.service are both Type=oneshot with
> no [Install] section. foo.timer declares Unit=foo.service, which causes
> foo.service to run whenever the timer triggers. That's simple enough,
> and I have that working.
>
> I want bar.service to run after foo.service completes, as it operates on
> some data generated by foo.service. I'm not sure what the magic bits are
> to make this work. I could obviously work around the issue by wrapping
> the logic for the two jobs in a shell script that runs the two actions
> sequentially, but I rather like the logging and status utilities
> provided by systemd, so having them as separate units seems preferable.
>
> --
> Evan Klitzke
> https://eklitzke.org/
> _______________________________________________
> systemd-devel mailing list
> systemd-***@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Andrei Borzenkov
2018-03-20 07:21:58 UTC
Permalink
Raw Message
Отправлено с iPhone

> 20 марта 2018 г., в 8:15, Andrei Borzenkov <***@gmail.com> написал(а):
>
> The simplest way is to add Wants=bar.service and After=bar.service to foo.service.

I mean of course Before=bar.service


>
> Отправлено с iPhone
>
>> 20 марта 2018 г., в 7:44, Evan Klitzke <***@eklitzke.org> написал(а):
>>
>> I am wondering how to create a cascade of oneshot units that should run
>> on a timer. What I'm imagining is something like the following:
>>
>> foo.timer
>> foo.service
>> bar.service
>>
>> In this example foo.service and bar.service are both Type=oneshot with
>> no [Install] section. foo.timer declares Unit=foo.service, which causes
>> foo.service to run whenever the timer triggers. That's simple enough,
>> and I have that working.
>>
>> I want bar.service to run after foo.service completes, as it operates on
>> some data generated by foo.service. I'm not sure what the magic bits are
>> to make this work. I could obviously work around the issue by wrapping
>> the logic for the two jobs in a shell script that runs the two actions
>> sequentially, but I rather like the logging and status utilities
>> provided by systemd, so having them as separate units seems preferable.
>>
>> --
>> Evan Klitzke
>> https://eklitzke.org/
>> _______________________________________________
>> systemd-devel mailing list
>> systemd-***@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Evan Klitzke
2018-03-20 08:49:37 UTC
Permalink
Raw Message
Andrei Borzenkov <***@gmail.com> writes:
>> The simplest way is to add Wants=bar.service and After=bar.service to
>> foo.service.
>
> I mean of course Before=bar.service

Indeed that seems to work! Thanks for your help.
Loading...