LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-01-2016, 05:06 PM   #1
genogebot
Member
 
Registered: Jun 2010
Location: Brisbane, Australia
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146

Rep: Reputation: 19
systemd timers - why is random time added repeatedly?


I understand how to add randomization to systemd timers via the 'RandomizedDelaySec=' value, but in looking at the journald logs I've noticed that the timer randomization often occurs multiple times in quick succession, and I'm curious about why that happens.

For example, on my home network server I have a custom service that runs once a day at 5:00am to send me an email listing all of the errors in the journald log for the previous day. This is the timer script:
Code:
[Unit]
Description=Run send_journald_log_list.service on schedule

[Timer]
OnCalendar=05:00:00
RandomizedDelaySec=3600
Persistent=true

[Install]
WantedBy=timers.target
I would have expected the timer randomization to occur at most once per day, or perhaps once after each run, but the journald logs show that it happens multiple times during a short space of time:
Code:
$ journalctl -b --since="yesterday" | grep send_journald_log_list.timer
Nov 01 05:45:22 emachine systemd[1]: send_journald_log_list.timer: Adding 39min 5.884130s random time.
Nov 01 05:45:22 emachine systemd[1]: send_journald_log_list.timer: Adding 24min 59.880192s random time.
Nov 02 05:25:19 emachine systemd[1]: send_journald_log_list.timer: Adding 313.440ms random time.
Nov 02 05:25:19 emachine systemd[1]: send_journald_log_list.timer: Adding 37min 51.809861s random time.
Nov 02 06:02:34 emachine systemd[1]: send_journald_log_list.timer: Adding 50min 50.466119s random time.
Nov 02 06:02:37 emachine systemd[1]: send_journald_log_list.timer: Adding 39min 731.228ms random time.
Nov 02 06:02:39 emachine systemd[1]: send_journald_log_list.timer: Adding 34.313427s random time.
Nov 02 06:02:41 emachine systemd[1]: send_journald_log_list.timer: Adding 48min 43.602046s random time.
Nov 02 06:02:49 emachine systemd[1]: send_journald_log_list.timer: Adding 18min 20.856331s random time.
From the log entries, I can see that this morning random time was added 7 times in the space of less than 40 minutes - two of which appear to be simultaneous. Yesterday it only happened twice, suggesting that perhaps the randomization is itself randomized.

I've hunted around the net looking for information on this aspect of systemd timers but I haven't found anything yet. Before digging into the systemd source code, I thought I'd ask here and see if anyone knows why this happens.

(And yes, I am running Ubuntu 16.04 x64 server on an old ultra-low-spec headless 'emachine' desktop computer - and it works very well )
 
Old 11-01-2016, 05:42 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,702

Rep: Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548
How many similar events do you have firing simultaneously ?. If just that one, remove the parm. Else maybe alter the start time.
I'd be guessing a jittery clock source.
 
Old 11-01-2016, 05:59 PM   #3
genogebot
Member
 
Registered: Jun 2010
Location: Brisbane, Australia
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by syg00 View Post
How many similar events do you have firing simultaneously ?. If just that one, remove the parm. Else maybe alter the start time.
I'd be guessing a jittery clock source.
Thanks for the response. I'm not particularly concerned about this, just curious. My suspicion is that it's a systemd feature/bug - although if it was a 'feature' I would expect to find some documentation about it somewhere, and so far I haven't found anything. Not that it causes any kind of problem, it just seems pointless to repeat the randomization, and to me that suggests a misconfiguration or perhaps sloppy coding.

I get the same thing occurring on each of my 6 Ubuntu-variant systems, so I don't think the clock source is the cause.
 
Old 11-01-2016, 06:31 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,702

Rep: Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548Reputation: 3548
Use a distro that knows how to set up systemd properly then ...
I generally use Arch and Fedora and haven't heard of similar - I'll have to check if I even use that anywhere; did look into it a while ago.
 
Old 11-01-2016, 08:08 PM   #5
genogebot
Member
 
Registered: Jun 2010
Location: Brisbane, Australia
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146

Original Poster
Rep: Reputation: 19
As seems to be my habit, after starting this thread I did a new net search with slightly different search terms and got a couple of hits:

https://answers.launchpad.net/ubuntu/+question/292196 and https://lists.debian.org/deity/2016/04/msg00047.html

Both hits show the same multiple randomizations behaviour of 'RandomizedDelaySec' in a systemd timer. One is for Ubuntu, and the other Debian, so it looks like a bug/feature that goes upstream to Debian at least.
 
Old 11-02-2016, 03:23 PM   #6
genogebot
Member
 
Registered: Jun 2010
Location: Brisbane, Australia
Distribution: Xubuntu 16.04.1 / Linux Mint 18 XFCE / Linux Mint 18 Mate / Ubuntu Server 16.04.1 / Lubuntu 16.04.1
Posts: 146

Original Poster
Rep: Reputation: 19
This seems to be related to this Ubuntu bug: https://bugs.launchpad.net/ubuntu/+s...d/+bug/1576536, so I'll mark this thread as 'solved'.
 
  


Reply

Tags
random, systemd, timer


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding the exact Time Value for the Computer Programs with the aid of Kernel Timers $u$hil_k$ Linux - Newbie 4 02-01-2013 05:54 PM
Time problem in systemd rng Linux - General 0 06-13-2012 11:17 PM
ACE REACTOR timers or POSIX timers sbauer72 Programming 4 02-26-2012 04:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration