3

Here is my timer:

[Unit]
Description=Do whatever

[Timer]
OnCalendar=daily UTC

[Install]
WantedBy=timers.target

It fails to start with the following error:

Failed to start mytimer.timer: Unit mytimer.timer failed to load: Invalid argument. See system logs and 'systemctl status mytimer.timer' for details.

Sadly systemctl status doesn't add any clarity to the error message

But, if I remove the UTC literal, it works perfectly:

[Unit]
Description=Do whatever

[Timer]
OnCalendar=daily

[Install]
WantedBy=timers.target

What am I doing wrong?

This document describes the format accepted by OnCalendar, and it shows that UTC can be used.

Yes, I tried using quotes - doesn't help. I also tried using the normalized form - same thing

Versions:

  • OS: CentOS 7
  • kernel: 3.10.0-042stab113.21
  • systemd: systemd-219-19.el7_2.9.x86_64
4

Using OnCalendar= with any timestamp suffixed by UTC requires systemd 228 or later. This functionality was added in systemd 228.

From the systemd changelog:

CHANGES WITH 228:

...

  • Wherever systemd expects a calendar timestamp specification (like in journalctl's --since= and --until= switches) UTC timestamps are now supported. Timestamps suffixed with "UTC" are now considered to be in Universal Time Coordinated instead of the local timezone. Also, timestamps may now optionally be specified with sub-second accuracy. Both of these additions also apply to recurring calendar event specification, such as OnCalendar= in timer units.
  • 1
    It is a best practice to run servers in UTC time whenever possible anyway, so you may find that that is an effective workaround. – Michael Hampton Mar 24 '17 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.