Claudio4's wiki

Search IconIcon to open search

Systemd timers

Last updated

Systemd timers execute systemd units at schelude.

The unit can be selected with Unit= parameter, if no unit is declared then systemd will asume the unit shares the name with timer.

1
2
3
4
5
6
7
8
# myservice.timer
[Unit]
Description=Runs myservice every minue

[Timer]
OnCalendar=*-*-* *:00/1:00
[Install]
WantedBy=timers.target

Additonal parameters:

List timers

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
systemctl list-timers
NEXT                        LEFT          LAST                        PASSED        UNIT                         ACTIVA>
Tue 2022-03-29 13:18:00 UTC 36s left      Tue 2022-03-29 13:17:22 UTC 915ms ago     update-ipset.timer           update>
Tue 2022-03-29 14:03:55 UTC 46min left    Tue 2022-03-29 03:09:11 UTC 10h ago       motd-news.timer              motd-n>
Tue 2022-03-29 15:01:58 UTC 1h 44min left Tue 2022-03-29 08:49:07 UTC 4h 28min ago  ua-timer.timer               ua-tim>
Tue 2022-03-29 19:24:07 UTC 6h left       Mon 2022-03-28 19:24:07 UTC 17h ago       systemd-tmpfiles-clean.timer system>
Tue 2022-03-29 19:30:58 UTC 6h left       Tue 2022-03-29 13:12:28 UTC 4min 54s ago  apt-daily.timer              apt-da>
Wed 2022-03-30 06:35:06 UTC 17h left      Tue 2022-03-29 06:02:24 UTC 7h ago        apt-daily-upgrade.timer      apt-da>
Sun 2022-04-03 03:10:14 UTC 4 days left   Sun 2022-03-27 03:10:12 UTC 2 days ago    e2scrub_all.timer            e2scru>
Mon 2022-04-04 00:00:00 UTC 5 days left   Mon 2022-03-28 00:00:28 UTC 1 day 13h ago fstrim.timer                 fstrim>

8 timers listed.

Checking onCalendar value

use systemd-analyze calendar to view information about your calendar string.

1
2
3
4
systemd-analyze calendar '*-*-* *:00/1:00'
Normalized form: *-*-* *:00/1:00
    Next elapse: Tue 2022-03-29 13:20:00 UTC
       From now: 32s left

Interactive Graph