Discussion:
Strange systemd timer behaviour
(too old to reply)
Grimble
2022-08-12 09:31:30 UTC
Permalink
I was interested to see if I could launch a small program at one-second
intervals, so I wrote a small python script to write a two variable row
to a database (timestamp, 10 character string). Not wanting to create
the X.service/X.timer entries in /etc/systemd/, I set up a transient
systemd timer as follows:
systemd-run --timer-property=AccuracySec=1us --on-calendar '*:*:1'
/home/graeme/Software/Python/write1.py
expecting the '*:*:1' string to be interpreted as every second.
However results were very strange:
2022-08-11 15:00:01.04493 | abcdefghij
2022-08-11 15:00:01.04534 | abcdefghij
2022-08-11 15:00:01.045509 | abcdefghij
2022-08-11 15:00:01.046762 | abcdefghij
2022-08-11 15:00:01.047677 | abcdefghij
2022-08-11 15:00:10.040712 | abcdefghij
2022-08-11 15:01:01.044398 | abcdefghij
2022-08-11 15:01:01.044442 | abcdefghij
2022-08-11 15:01:01.045927 | abcdefghij
2022-08-11 15:01:01.045973 | abcdefghij
2022-08-11 15:01:01.046043 | abcdefghij
2022-08-11 15:01:10.041792 | abcdefghij
2022-08-11 15:02:01.045485 | abcdefghij
2022-08-11 15:02:01.045624 | abcdefghij
2022-08-11 15:02:01.045988 | abcdefghij
2022-08-11 15:02:01.047145 | abcdefghij
2022-08-11 15:02:01.048968 | abcdefghij
2022-08-11 15:02:10.042064 | abcdefghij

In other words, 5 firings within a very short time followed by one 10
seconds later. This behaviour was consistent over a 40 hour period.

Over a shorter period, replacing the string with '*:*:10' (?every 10
seconds?) gave
2022-08-11 15:27:01.045152 | abcdefghij
2022-08-11 15:27:01.045541 | abcdefghij
2022-08-11 15:27:01.046604 | abcdefghij
2022-08-11 15:27:01.04555 | abcdefghij
2022-08-11 15:27:01.048399 | abcdefghij
2022-08-11 15:27:10.042014 | abcdefghij
2022-08-11 15:27:10.042807 | abcdefghij

5 firings within 3 millisecs followed by 2 firings

Over a shorter period, replacing the string with '*:1:00' (?every 1
minute?) gave the same results as the '*:*;1' string.

Have I misunderstood the specification of the "on-calendar" parameter?
--
Grimble
Machine 'Haydn' running Plasma 5.20.4 on 5.15.58-desktop-2.mga8 kernel.
Mageia release 8 (Official) for x86_64
David W. Hodgins
2022-08-13 01:53:46 UTC
Permalink
Post by Grimble
I was interested to see if I could launch a small program at one-second
intervals, so I wrote a small python script to write a two variable row
to a database (timestamp, 10 character string). Not wanting to create
the X.service/X.timer entries in /etc/systemd/, I set up a transient
systemd-run --timer-property=AccuracySec=1us --on-calendar '*:*:1'
/home/graeme/Software/Python/write1.py
expecting the '*:*:1' string to be interpreted as every second.
2022-08-11 15:00:01.04493 | abcdefghij
2022-08-11 15:00:01.04534 | abcdefghij
<snip>
Post by Grimble
Have I misunderstood the specification of the "on-calendar" parameter?
I've never used systemd-run. On Mageia 8 none of the man pages mention
--timer-property=AccuracySec. That may be something that was added in a
newer version of systemd.

Mageia 8 has version 246. The online documentation mentions "By default, the
timer will execute a random amount of time between when the specified time is
reached, and one minute after"

Since the m8 version doesn't appear to support the timer-property so gets the
random timing.

Cauldron currently has systemd version 251.

Are you using m8 or a cauldron install?

Regards, Dave Hodgins
Bit Twister
2022-08-13 02:34:35 UTC
Permalink
Post by David W. Hodgins
Post by Grimble
I was interested to see if I could launch a small program at one-second
intervals, so I wrote a small python script to write a two variable row
to a database (timestamp, 10 character string). Not wanting to create
the X.service/X.timer entries in /etc/systemd/, I set up a transient
systemd-run --timer-property=AccuracySec=1us --on-calendar '*:*:1'
/home/graeme/Software/Python/write1.py
expecting the '*:*:1' string to be interpreted as every second.
2022-08-11 15:00:01.04493 | abcdefghij
2022-08-11 15:00:01.04534 | abcdefghij
<snip>
Post by Grimble
Have I misunderstood the specification of the "on-calendar" parameter?
I've never used systemd-run. On Mageia 8 none of the man pages mention
--timer-property=AccuracySec. That may be something that was added in a
newer version of systemd.
Mageia 8 has version 246. The online documentation mentions "By default, the
timer will execute a random amount of time between when the specified time is
reached, and one minute after"
Since the m8 version doesn't appear to support the timer-property so gets the
random timing.
Cauldron currently has systemd version 251.
Are you using m8 or a cauldron install?
A quick
man -k systemd | grep -i time
give several selections on my mga 8 release.

$ man systemd.timer
and doing a
/AccuracySec
for searching gets me a AccuracySec description.
David W. Hodgins
2022-08-13 03:24:48 UTC
Permalink
Post by Bit Twister
Post by David W. Hodgins
Post by Grimble
I was interested to see if I could launch a small program at one-second
intervals, so I wrote a small python script to write a two variable row
to a database (timestamp, 10 character string). Not wanting to create
the X.service/X.timer entries in /etc/systemd/, I set up a transient
systemd-run --timer-property=AccuracySec=1us --on-calendar '*:*:1'
/home/graeme/Software/Python/write1.py
expecting the '*:*:1' string to be interpreted as every second.
2022-08-11 15:00:01.04493 | abcdefghij
2022-08-11 15:00:01.04534 | abcdefghij
<snip>
Post by Grimble
Have I misunderstood the specification of the "on-calendar" parameter?
I've never used systemd-run. On Mageia 8 none of the man pages mention
--timer-property=AccuracySec. That may be something that was added in a
newer version of systemd.
Mageia 8 has version 246. The online documentation mentions "By default, the
timer will execute a random amount of time between when the specified time is
reached, and one minute after"
Since the m8 version doesn't appear to support the timer-property so gets the
random timing.
Cauldron currently has systemd version 251.
Are you using m8 or a cauldron install?
A quick
man -k systemd | grep -i time
give several selections on my mga 8 release.
$ man systemd.timer
and doing a
/AccuracySec
for searching gets me a AccuracySec description.
That's for timer files such as /etc/systemd/system/fstrim.timer, not for the
systemd-run command.

Regards, Dave Hodgins
Grimble
2022-08-16 15:26:23 UTC
Permalink
On Fri, 12 Aug 2022 22:34:35 -0400, Bit Twister
Post by Bit Twister
On Fri, 12 Aug 2022 05:31:30 -0400, Grimble
Post by Grimble
I was interested to see if I could launch a small program at one-second
intervals, so I wrote a small python script to write a two variable row
to a database (timestamp, 10 character string). Not wanting to create
the X.service/X.timer entries in /etc/systemd/, I set up a transient
  systemd-run --timer-property=AccuracySec=1us --on-calendar '*:*:1'
/home/graeme/Software/Python/write1.py
expecting the '*:*:1' string to be interpreted as every second.
  2022-08-11 15:00:01.04493  | abcdefghij
  2022-08-11 15:00:01.04534  | abcdefghij
<snip>
Post by Grimble
Have I misunderstood the specification  of the "on-calendar" parameter?
I've never used systemd-run. On Mageia 8 none of the man pages mention
--timer-property=AccuracySec. That may be something that was added in a
newer version of systemd.
Mageia 8 has version 246. The online documentation mentions "By default, the
timer will execute a random amount of time between when the specified time is
reached, and one minute after"
Since the m8 version doesn't appear to support the timer-property so gets the
random timing.
Cauldron currently has systemd version 251.
Are you using m8 or a cauldron install?
A quick
  man -k systemd | grep -i time
give several selections on my mga 8 release.
$ man systemd.timer
and doing a
   /AccuracySec
for searching gets me a AccuracySec description.
That's for timer files such as /etc/systemd/system/fstrim.timer, not for the
systemd-run command.
Regards, Dave Hodgins
Thanks both for your comments. After further reading and testing, it
seems not to be possible to have a shorter timer interval than 1 minute.
(Oops- it also seems that the multiple entries was because I had left
more than one timer running)
--
Grimble
Machine 'Haydn' running Plasma 5.20.4 on 5.15.58-desktop-2.mga8 kernel.
Mageia release 8 (Official) for x86_64
Loading...