Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1074951 - RFE: Introduce "Between" to timer units
RFE: Introduce "Between" to timer units
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: systemd (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: systemd-maint
Fedora Extras Quality Assurance
:
Depends On:
Blocks: systemd-RFE
  Show dependency treegraph
 
Reported: 2014-03-11 05:37 EDT by Jóhann B. Guðmundsson
Modified: 2016-02-01 02:54 EST (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-01-22 03:23:12 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jóhann B. Guðmundsson 2014-03-11 05:37:49 EDT
Description of problem:

We can ease the life of batch server administrators having to keep taps on thousands of scheduled job and manually increment each of them if they happen within the same time period by simply introduce randomized run times between two defined calendar times,

Sample 

"I want my scheduled job to run sometime between 05:00 and 06:00 in the morning"
( Between=05:00,06:00 )

or 

"I want my scheduled job to run sometime between Saturday or Sunday"
( Between=sat,sun )

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
Comment 1 Zbigniew Jędrzejewski-Szmek 2014-03-11 23:08:15 EDT
I think that AccuracySec= already makes this possible.

OnCalendar=5:00
AccuracySec=1h
Comment 2 Jóhann B. Guðmundsson 2014-03-12 01:34:09 EDT
AccuracySec= is missing in the man pages for systemd 208 ( F20 )  and I dont think it crosses over days as in you cannot specify time period between days like weekends ( common time window for batch jobs to be run on servers )

Not usage friendly as in 

OnCalendar=5:00
AccuracySec=1h

Reads to me run at 6:00 even thou it might be randomized within a whole hour afterwards and it seems to be bound to a switch in systemd-system.conf ( ( TimerSlackNSec= ) which is one thing I dont think we want. 

Basically you dont want to add a master switch that can easily disrupt heavily loaded batch server with schedule jobs in the hundreds and thousands.
Comment 3 Zbigniew Jędrzejewski-Szmek 2014-03-12 08:29:34 EDT
Those are new settings, so they are not present in stable Fedora.

TimerSlack is a different order of magnitude: it has a default value of 50us and probably should not be set to something higher than a few ms. OTOH, AccuracySec should work fine, even with periods of more than one day. All in all, I don't see too much problem with OnCalendar= + AccuracySec=. Note that this should work for all time specifications (OnCalendard=, OnBoot=...), and work fine with timer specifications which contain a dash.
Comment 4 Jóhann B. Guðmundsson 2014-03-12 08:52:09 EDT
(In reply to Zbigniew Jędrzejewski-Szmek from comment #3)
> Those are new settings, so they are not present in stable Fedora.
> 
> TimerSlack is a different order of magnitude: it has a default value of 50us
> and probably should not be set to something higher than a few ms. OTOH,
> AccuracySec should work fine, even with periods of more than one day. All in
> all, I don't see too much problem with OnCalendar= + AccuracySec=. Note that
> this should work for all time specifications (OnCalendard=, OnBoot=...), and
> work fine with timer specifications which contain a dash.

I'm not so sure using AccuracySec solves this problem that batch administrator are faced with from a usability perspective as in

01 1 * * * 
02 1 * * *
03 1 * * * 
04 1 * * *
05 1 * * * 
06 1 * * *
07 1 * * * 
08 1 * * *
etc... 

Which could be solved by defining randomly run schedule within a given time frame

And if "AccuracySec" can solve this it is in no way descriptive name for that purpose
Comment 5 Zbigniew Jędrzejewski-Szmek 2014-03-12 09:29:14 EDT
(In reply to Jóhann B. Guðmundsson from comment #4)
> (In reply to Zbigniew Jędrzejewski-Szmek from comment #3)
> > Those are new settings, so they are not present in stable Fedora.
> > 
> > TimerSlack is a different order of magnitude: it has a default value of 50us
> > and probably should not be set to something higher than a few ms. OTOH,
> > AccuracySec should work fine, even with periods of more than one day. All in
> > all, I don't see too much problem with OnCalendar= + AccuracySec=. Note that
> > this should work for all time specifications (OnCalendard=, OnBoot=...), and
> > work fine with timer specifications which contain a dash.
> 
> I'm not so sure using AccuracySec solves this problem that batch
> administrator are faced with from a usability perspective as in
> 
> 01 1 * * * 
> 02 1 * * *
> 03 1 * * * 
> 04 1 * * *
> 05 1 * * * 
> 06 1 * * *
> 07 1 * * * 
> 08 1 * * *
> etc... 
> 
> Which could be solved by defining randomly run schedule within a given time
> frame
If I understand your requirements correctly, this is what AccuracySec does.

> And if "AccuracySec" can solve this it is in no way descriptive name for
> that purpose
We should probably add some pointer in the On*= section to this setting.
Comment 6 Lennart Poettering 2014-03-12 09:55:08 EDT
AccuracySec= should cover this, starting with 209+. However, it will only really place the wakeup within 1min of range at max. If you set larger values it won't care... we can certainly change that though.

And we could add DefaultAccuracySec= to system.conf I figure...
Comment 7 Jóhann B. Guðmundsson 2014-03-12 10:21:31 EDT
(In reply to Lennart Poettering from comment #6)
> AccuracySec= should cover this, starting with 209+. However, it will only
> really place the wakeup within 1min of range at max. If you set larger
> values it won't care... we can certainly change that though.

I was wondering about that as in how well definable this actually was since the randomness needs to take place on a second level so when users define 

OnCalendar=5:00
AccuracySec=1m

It would run on a random second sometime in a 60s second range after 05:00 in the morning 

Or for an hour

OnCalendar=5:00
AccuracySec=1h

It would run on a random second sometime in a 3600 second range after 05:00 in the morning

Or for a full day

OnCalendar=5:00
AccuracySec=1d

It would run on a random second sometime in a 86400 second range after 05:00 in the morning 

Or for a two full days ( like a weekend )

OnCalendar=5:00
AccuracySec=2d

It would run on a random second sometime in a 172800 second range after 05:00 in the morning 

Etc.

> And we could add DefaultAccuracySec= to system.conf I figure...

I dont see the benefits of having such switch but maybe I'm missing something.
Comment 8 Zbigniew Jędrzejewski-Szmek 2016-01-27 10:02:03 EST
This got implemented as RandomizedDelay:
http://www.freedesktop.org/software/systemd/man/systemd.timer.html#RandomSec=
Comment 9 Edgar Hoch 2016-01-30 01:09:23 EST
(In reply to Zbigniew Jędrzejewski-Szmek from comment #8)
> This got implemented as RandomizedDelay:
> http://www.freedesktop.org/software/systemd/man/systemd.timer.html#RandomSec=

Would it be possible to provide this feature in Fedora 23?

Either upgradeing to a higher systemd release, or backporting this feature to systemd 222 if you don't want to upgrade to a higher systemd release on Fedora 23?


I have tried to use AccuracySec to randomize the start time, as suggested in earlier comments, but it didn't work as expected. The timer has started the service within the first minute.

I need this feature to restrict dnf-automatic activation to the night (01:00h - 06:00h), because dnf update requests many disk ios and slow down interactive usage on the graphical console nearly to unuseability. But hundred of machines should not start dnf upgrade at the same time, they may get network connection timeouts.
Comment 10 Jan Synacek 2016-02-01 02:54:02 EST
(In reply to Edgar Hoch from comment #9)
> (In reply to Zbigniew Jędrzejewski-Szmek from comment #8)
> > This got implemented as RandomizedDelay:
> > http://www.freedesktop.org/software/systemd/man/systemd.timer.html#RandomSec=
> 
> Would it be possible to provide this feature in Fedora 23?

Yes, the patch is simple enough. Please, file a request for Fedora 23 and put this bugzilla in the "See Also" section, thank you.

Note You need to log in before you can comment on or make changes to this bug.