You are not logged in.

#1 2016-01-09 17:09:59

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 291

{solved] systemd/timer question

I came up with this to sync a local repository for my local clients so I'm not downloading all updates from the internet for each client.

[Unit]
Description=sync-local-repo 1min after boot and 60 mins after each completion with random delay of 0-10minst
RefuseManualStart=no
RefuseManualStop=no

[Timer]
Persistent=false
RandomSec=10min
OnBootSec=1min
OnUnitInactiveSec=75min
Unit=sync-local-repo.service

[Install]
WantedBy=timers.target

I think it should be obvious what I'm trying to do:
- start a sync 1 minute after boot
- sync 75 minutes after completing the previous run
- random delay by 0-10 minutes of each run

I wanted to ask if the above is correct. The info I find (especially on the actual timers) is confusing. Sometimes I see only numbers, sometimes spelled out like "20 minutes", sometimes just "20m", others use spaces. I'm not getting error messages so I think I'm good.

PS. I'm incredibly dim, I admit up front. But what does the "Sec" stand for? RandomSec, OnBootSec, OnUnitInactiveSec? :S

Thanks for the help!

Last edited by mouseman (2016-01-10 08:49:47)

Offline

#2 2016-01-09 18:10:35

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: {solved] systemd/timer question

mouseman wrote:

PS. I'm incredibly dim, I admit up front. But what does the "Sec" stand for?

Seconds:

man systemd.timer wrote:

The arguments to the directives are time spans configured in seconds. Example: "OnBootSec=50" means 50s after boot-up. The argument may also include time units. Example: "OnBootSec=5h 30min" means 5 hours and 30 minutes after boot-up. For details about the syntax of time spans, see systemd.time(7).

Offline

#3 2016-01-09 18:27:58

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 291

Re: {solved] systemd/timer question

Raynman wrote:
mouseman wrote:

PS. I'm incredibly dim, I admit up front. But what does the "Sec" stand for?

Seconds:

man systemd.timer wrote:

The arguments to the directives are time spans configured in seconds. Example: "OnBootSec=50" means 50s after boot-up. The argument may also include time units. Example: "OnBootSec=5h 30min" means 5 hours and 30 minutes after boot-up. For details about the syntax of time spans, see systemd.time(7).

I did read the wiki, it just didn't stick as I've been reading too much wink.

That's what I thought though, what threw me off was that it takes every kind of time specification, not just seconds. I see it defaults to seconds if you don't specify it then.

Cool!

Offline

#4 2016-01-09 20:32:53

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 291

Re: {solved] systemd/timer question

RandomSec=10min

and

OnUnitInactiveSec=75min

Doesn't seem to work. Each scheduled start is within seconds of the other ones' end on the interval.

Appreciate it someone could help me out on this.

Thanks!

Offline

#5 2016-01-09 20:51:49

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: {solved] systemd/timer question

I don't see RandomSec in the man page (systemd.directives). Searching through the github repo, it was introduced in November after the latest stable release (and renamed not long after that). Are there no warnings about unrecognized options in the journal?

Offline

#6 2016-01-10 08:49:34

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 291

Re: {solved] systemd/timer question

Yeah there was, noticed that last night too.

Thanks for the link. RandomizedDelaySec doesn't work either. I suppose I have to wait for that. No biggie, I can use a random sleep for now in my script I'm calling.

OnUnitInactiveSec works too, runtimes were too short last night to make them stand out and they always vary somewhat, but overnight I had a few that took more than a few minutes to complete and I can see the next one starts 75 minutes after the last one closed.

Thanks for the help Raynman.

Offline

Board footer

Powered by FluxBB