Skip to content

Instantly share code, notes, and snippets.

@z3dm4n
Last active November 2, 2023 13:47
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z3dm4n/2b6a6a6d795f6fc880371a0088839cb1 to your computer and use it in GitHub Desktop.
Save z3dm4n/2b6a6a6d795f6fc880371a0088839cb1 to your computer and use it in GitHub Desktop.
Using systemd-run as atd replacement to run jobs at scheduled times
$ sudo systemd --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

$ sudo systemd-run --property=WorkingDirectory=/foo/bar --property=TimeoutSec=5min --on-active="10min" command args
Running timer as unit: run-1.timer
Will run service as unit: run-1.service

$ sudo systemctl list-timers

$ sudo systemctl show run-1.service

$ sudo journalctl -u run-1.service

$ sudo systemd-run --property=WorkingDirectory=/foo/bar --property=TimeoutSec=5min --on-calendar="2020-02-29 06:00:00" command args
Running timer as unit: run-2.timer
Will run service as unit: run-2.service

$ sudo systemctl list-timers

$ sudo systemctl show run-2.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment