Discussion:
Add timer exception
(too old to reply)
Andy Pieters
2018-11-05 08:36:38 UTC
Permalink
Dear Systemd list

I have got a job that I want to execute every other day.

The job is rather lengthy and takes more than 24 hours to complete but
less than 48.

So here are my criteria:

Start today
Start the day after tomorrow (t+2d)*1
Start the (t+2d)*2
Start 2 days after that (t+2d)*n


My timer unit:

[Timer]
OnCalendar=*-*-01,03,05,07,09,11,13,15,17,19,21,23,25,27,29,31 03:30:00

The problem with that is when I simulate the execution dates,
specifically at newyear:

Tue 2018-12-25 03:30:00 CET
Thu 2018-12-27 03:30:00 CET
Sat 2018-12-29 03:30:00 CET
Mon 2018-12-31 03:30:00 CET
Tue 2019-01-01 03:30:00 CET
Thu 2019-01-03 03:30:00 CET
Sat 2019-01-05 03:30:00 CET
Mon 2019-01-07 03:30:00 CET
Wed 2019-01-09 03:30:00 CET

We can see that the timer would be triggered two days in a row.

What can we do about this, please? Is there a better way to define a
timer to run every other day? Can we perhaps add an exception for a
specific date?

Thank you kindly

Keep up the good work!



Andy
Jérémy Rosen
2018-11-05 09:05:42 UTC
Permalink
I would have my timer be duration-based instead of calandar based
(assuming that fits your need)

You could use one of the following

OnActiveSec=48h (two days after the timer last triggered
OnUnitActiveSec=48h (two days afte the unit was last started)

Or slightly different

OnUnitInactiveSec=24h (one day after the service FINISHED)

In all those cases, since this is interval based, you would need a way
to "prime the pump" I usually do this with

OnStartupSec=15m (1/4h after the machine was started)

or simply by enabling the service itself so it's part of the boot
sequence (this will work with OnUnitActive and OnUnitInactive, but not
with OnActive)
Post by Andy Pieters
Dear Systemd list
I have got a job that I want to execute every other day.
The job is rather lengthy and takes more than 24 hours to complete but
less than 48.
Start today
Start the day after tomorrow (t+2d)*1
Start the (t+2d)*2
Start 2 days after that (t+2d)*n
[Timer]
OnCalendar=*-*-01,03,05,07,09,11,13,15,17,19,21,23,25,27,29,31 03:30:00
The problem with that is when I simulate the execution dates,
Tue 2018-12-25 03:30:00 CET
Thu 2018-12-27 03:30:00 CET
Sat 2018-12-29 03:30:00 CET
Mon 2018-12-31 03:30:00 CET
Tue 2019-01-01 03:30:00 CET
Thu 2019-01-03 03:30:00 CET
Sat 2019-01-05 03:30:00 CET
Mon 2019-01-07 03:30:00 CET
Wed 2019-01-09 03:30:00 CET
We can see that the timer would be triggered two days in a row.
What can we do about this, please? Is there a better way to define a
timer to run every other day? Can we perhaps add an exception for a
specific date?
Thank you kindly
Keep up the good work!
Andy
_______________________________________________
systemd-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
SMILE <http://www.smile.eu/>

20 rue des Jardins
92600 AsniÚres-sur-Seine


*Jérémy ROSEN*
Architecte technique
Responsable de l'expertise Smile-ECS

email ***@smile.fr <mailto:***@smile.fr>
phone +33141402967
url http://www.smile.eu

Twitter <https://twitter.com/GroupeSmile> Facebook
<https://www.facebook.com/smileopensource> LinkedIn
<https://www.linkedin.com/company/smile> Github
<https://github.com/Smile-SA>


Découvrez l’univers Smile, rendez-vous sur smile.eu
<http://smile.eu/?utm_source=signature&utm_medium=email&utm_campaign=signature>

eco Pour la planÚte, n'imprimez ce mail que si c'est nécessaire
Andy Pieters
2018-11-05 09:58:37 UTC
Permalink
Post by Jérémy Rosen
I would have my timer be duration-based instead of calandar based
(assuming that fits your need)
You could use one of the following
OnActiveSec=48h (two days after the timer last triggered
OnUnitActiveSec=48h (two days afte the unit was last started)
Or slightly different
OnUnitInactiveSec=24h (one day after the service FINISHED)
In all those cases, since this is interval based, you would need a way to
"prime the pump" I usually do this with
OnStartupSec=15m (1/4h after the machine was started)
or simply by enabling the service itself so it's part of the boot sequence
(this will work with OnUnitActive and OnUnitInactive, but not with OnActive)
Ok but I don't want to have to wait until 3.30AM to manually prime the
thing, and I don't want to start it outside of its normal run window...
Lennart Poettering
2018-11-05 13:38:45 UTC
Permalink
Post by Andy Pieters
Post by Jérémy Rosen
OnUnitInactiveSec=24h (one day after the service FINISHED)
In all those cases, since this is interval based, you would need a way to
"prime the pump" I usually do this with
OnStartupSec=15m (1/4h after the machine was started)
or simply by enabling the service itself so it's part of the boot sequence
(this will work with OnUnitActive and OnUnitInactive, but not with OnActive)
Ok but I don't want to have to wait until 3.30AM to manually prime the
thing, and I don't want to start it outside of its normal run window...
Note that you can combined OnCalendar= (i.e. calendar time events) and
OnUnitInactiveSec= and friends (i.e. monotonic time events) in a
single .timer unit.

Lennart
--
Lennart Poettering, Red Hat
Andy Pieters
2018-11-05 21:14:28 UTC
Permalink
On Mon, Nov 5, 2018 at 2:38 PM Lennart Poettering
<***@poettering.net> wrote:
Note that you can combined OnCalendar= (i.e. calendar time events) and
Post by Lennart Poettering
OnUnitInactiveSec= and friends (i.e. monotonic time events) in a
single .timer unit.
Until this is implemented I think I will just do a

`at -t 201901010325 systemctl stop mytimer.timer`

and

`at -t 201901020330 systemctl start mytimer.timer`

Assuming no artefacts will arise from this?

Lennart Poettering
2018-11-05 13:37:33 UTC
Permalink
Post by Andy Pieters
What can we do about this, please? Is there a better way to define a
timer to run every other day? Can we perhaps add an exception for a
specific date?
A similar feature has been requested before: a way to configure
bi-weekly calendar events
(https://github.com/systemd/systemd/issues/6024)

If we add bi-weekly calendar events it would make a ton of sense to
also add bi-daily events (and other similar ones)

I would be great to add a concept for that, but so far nobody
suggested a nice syntax and a patch for it yet.

To deal nicely with the year-end issue I figure one option would be to
define a linear day/week/month index based on 1st jan 1970 and then
base repetitions on that, always adjusting things to the current
timezone correctly.

Lennart
--
Lennart Poettering, Red Hat
Kenneth Porter
2018-11-05 20:08:49 UTC
Permalink
--On Monday, November 05, 2018 2:37 PM +0100 Lennart Poettering
Post by Lennart Poettering
I would be great to add a concept for that, but so far nobody
suggested a nice syntax and a patch for it yet.
For prior art, take a look at the RRULE syntax in calendar files.

<https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html>
Continue reading on narkive:
Loading...