[systemd-devel] How to create a timer that will only run once?
Konstantin Kharlamov
Hi-Angel at yandex.ru
Tue Aug 27 14:28:10 UTC 2024
There's a popular usecase of human-readably scheduling a command for
later¹. There are multiple non-systemd solutions, but they generally
involve running a 3rd party service, such as atd for at.
This functional is provided by systemd though, e.g.:
systemd-run --user --on-calendar=12:10 systemctl suspend
There's just one problem: from now on this command will be running
daily, unless you modify the time to include the date. But not only
systemd doesn't allow syntax --on-calendar="today 12:10", even if it
did that would be prone to mistakes when a user has time 21:32 and they
think "I'm gonna schedule a command for today at 00:07", but that isn't
actually "today" but "tomorrow".
So, isn't there an option or something that would allow a user to
specify time without having to worry the timer is going to be executed
more than once?
----------
This was asked on IRC, but the only solution was suggested is doing
some arithmetics with `date` from GNU coreutils.
1:
https://askubuntu.com/questions/339298/conveniently-schedule-a-command-to-run-later
More information about the systemd-devel
mailing list