[systemd-devel] Antw: [EXT] Re: Q: Start a unit n minutes after a successful boot

Lennart Poettering lennart at poettering.net
Tue Sep 8 14:22:26 UTC 2020


On Di, 08.09.20 11:01, Ulrich Windl (Ulrich.Windl at rz.uni-regensburg.de) wrote:

> >> Configuring a new system with non‑redundant system disk I'm wondering:
> >> How could I start an automatic backup job that is triggered n minutes
> >> after the system started successfully (to avoid backing up broken
> >> configurations)?
> >
> >   Timer with "OnBootSec=n minutes" is exactly what you want, right?
>
> Hi!
>
> Is every boot a successful boot? Will (e.g.) default.target be reached even if
> some service failed? If not, that is what I had in mind:
> Start a unit n minutes after default.target was reached
> "sucessfully".

Define a timer unit like this if you want to make this dependent on
"default.target" having been reached.

    [Unit]
    Requisite=default.target
    After=default.target

    [Timer]
    OnActiveSec=2min

    [Install]
    WantedBy=timers.target

This will enqueue the timer during early boot, but not actually
activate it until default.target has been reached. Then once active,
after 2mn the associated service is triggered.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list