[systemd-devel] How to chain services driven by a timer?
Dan Nicholson
dbn at endlessos.org
Wed Apr 10 15:06:09 UTC 2024
On Wed, Apr 10, 2024 at 8:50 AM Brian Reichert <reichert at numachi.com> wrote:
>
> My current service file:
>
> [Unit]
> Description=Activities after logrotation
>
> Requires=logrotate.service
> Wants=logrotate.service
> After=logrotate.service
>
> [Service]
> #Type=oneshot
> Type=simple
>
> ExecStart=/usr/bin/logger 'XXX post log rotation'
>
> [Install]
> WantedBy=timers.target
The critical part is WantedBy=logrotate.service. In other words, when
logrotate.service is activated, you want it to also activate your
service. Then After=logrotate.service above will ensure your service
starts after it completes. The Requires and Wants above are
conflicting. You only want one or the other, but I'd probably put it
as Requires=logrotate.service. That way your unit won't start if
logrotate.service fails.
More information about the systemd-devel
mailing list