[systemd-devel] How to create a timer that will only run once?

Konstantin Kharlamov Hi-Angel at yandex.ru
Mon Sep 2 04:37:07 UTC 2024


On Thu, 2024-08-29 at 10:08 +0200, Lennart Poettering wrote:
> On Di, 27.08.24 17:28, Konstantin Kharlamov (Hi-Angel at yandex.ru)
> wrote:
> 
> > 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?
> 
> We currently have no mechanism for this. I guess we could extend the
> calendar time syntax with something like this, where we take the
> current time, and then alter it in certain ways you specify. File a
> github RFE issue about this.
> 
> Lennart
> 
> --
> Lennart Poettering, Berlin

Thank you, created an issue:
https://github.com/systemd/systemd/issues/34222


More information about the systemd-devel mailing list