You are not logged in.

#1 2018-01-17 20:11:20

luser
Member
Registered: 2016-08-27
Posts: 114

[SOLVED] Systemd timer fails to parse calendar specification

I am trying to update my mirrorlist every two days with a reflector.service and reflector.timer. My reflector.service works, but the reflector.timer does not run properly, it fails with the following information:

/etc/systemd/system/reflector.timer:5: Failed to parse calendar specification, ignoring: "Mon,Wed,Fri,Sat *-*-* 11:00:00"
Jan 16 21:01:26 RANDOM7 systemd[1]: reflector.timer: Timer unit lacks value setting. Refusing.

My reflector.timer looks like this:

[Unit]
Description=Run reflector every two days

[Timer]
OnCalendar="Mon,Wed,Fri,Sat *-*-* 11:00:00"
Persistent=true

[Install]
WantedBy=timers.target

I have tested the OnCalendar expression by using:

systemd-analyze calendar "Mon,Wed,Fri,Sat *-*-* 11:00:00"

and the result appears to be fine:

Normalized form: Mon,Wed,Fri,Sat *-*-* 11:00:00
    Next elapse: Fri 2018-01-19 11:00:00 PST
       (in UTC): Fri 2018-01-19 19:00:00 UTC
       From now: 1 day 22h left

What am I doing wrong here?

Last edited by luser (2018-01-18 09:24:33)


luser: an epithet applied by Windows users to linux users

Offline

#2 2018-01-17 20:33:47

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: [SOLVED] Systemd timer fails to parse calendar specification

Does it work if you remove the quotes?

Otherwise, try to see if there are special characters in there (try running hexdump or xxd to see the byte-representation of the file).


pkgshackscfgblag

Offline

#3 2018-01-17 20:35:03

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: [SOLVED] Systemd timer fails to parse calendar specification

Since the format is correct, you probably have to remove the quote marks.
Edit: ayekat beat me.

Last edited by progandy (2018-01-17 20:37:45)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#4 2018-01-17 22:47:23

luser
Member
Registered: 2016-08-27
Posts: 114

Re: [SOLVED] Systemd timer fails to parse calendar specification

I appreciate the responses.
I did not try removing the quotes when testing the service, though I did replace with single quotes which didn't work.

The reason I didn't try it without quotes, is that when I used "systemd-analyze calendar Mon,Wed,Fri,Sat *-*-* 11:00:00", I got an output that seemed too complicated vs trying it with the quotes, which simply output one result as shown earlier above. Here's the output without quotes: 

Original form: Mon,Wed,Fri,Sat
Normalized form: Mon,Wed,Fri,Sat *-*-* 00:00:00
    Next elapse: Fri 2018-01-19 00:00:00 PST
       (in UTC): Fri 2018-01-19 08:00:00 UTC
       From now: 1 day 9h left

  Original form: *-*-*
Normalized form: *-*-* 00:00:00
    Next elapse: Thu 2018-01-18 00:00:00 PST
       (in UTC): Thu 2018-01-18 08:00:00 UTC
       From now: 9h left

  Original form: 11:00:00
Normalized form: *-*-* 11:00:00
    Next elapse: Thu 2018-01-18 11:00:00 PST
       (in UTC): Thu 2018-01-18 19:00:00 UTC
       From now: 20h left

Nonetheless, when I remove the quotes, save the timer file, and 'systemd daemon-reload' and check the status of the timer, it seems OK. I am thinking it's resolved it, but I want to see it work before marking this issue resolved.

Last edited by luser (2018-01-17 22:55:38)


luser: an epithet applied by Windows users to linux users

Offline

#5 2018-01-17 22:55:23

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Systemd timer fails to parse calendar specification

OK, but what happens when you don't use quote in the timer file?

The systemd-analyze command you used is parsed by your shell, which explains the need for quotes. Systemd configuration files aren't so the quotes are being taken literally.

Last edited by Slithery (2018-01-17 23:10:16)


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2018-01-17 23:04:33

luser
Member
Registered: 2016-08-27
Posts: 114

Re: [SOLVED] Systemd timer fails to parse calendar specification

After looking things over, including the systemd timers wiki again, I believe what's happening is that it's necessary to use quotes when using systemd-analyze, but not when using OnCalendar in the timer file itself. This is not spelled out, but the examples are written that way, apparently for a reason. I'm marking this solved.

Thanks for pointing me in the right direction.

Last edited by luser (2018-01-18 09:25:28)


luser: an epithet applied by Windows users to linux users

Offline

#7 2018-01-18 09:33:03

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: [SOLVED] Systemd timer fails to parse calendar specification

luser wrote:

This is not spelled out, but the examples are written that way, apparently for a reason.

Yes, this is because of the way the shell works: spaces and asterisks have special meanings there, so you have to handle them specially in the shell (but not in systemd-unit files).

Instead of quotes, you could also type this:

systemd-analyze calendar Mon,Wed,Fri,Sat\ \*-\*-\*\ 11:00:00                                                                                                                                                                                                                                      
Normalized form: Mon,Wed,Fri,Sat *-*-* 11:00:00                                                                                                                                                                                                                                                               
    Next elapse: Fri 2018-01-19 11:00:00 CET                                                                                                                                                                                                                                                                  
       (in UTC): Fri 2018-01-19 10:00:00 UTC
       From now: 24h left

pkgshackscfgblag

Offline

Board footer

Powered by FluxBB