Am Sat, 22 Aug 2015 22:56:47 -0400 schrieb Fernando Rodriguez <frodriguez.develo...@outlook.com>:
> On Saturday, August 22, 2015 10:17:04 PM allan gottlieb wrote: > > On Sat, Aug 22 2015, Marc Joliet wrote: > > > > > Am Sat, 22 Aug 2015 17:15:38 -0400 > > > schrieb Fernando Rodriguez <frodriguez.develo...@outlook.com>: > > > > > >> On Saturday, August 22, 2015 4:52:47 PM allan gottlieb wrote: > > >> > I use systemd and wish to employ timers an analogue of cron.daily. > > >> > The > > >> system is a laptop that is normally turned off each evening. > > >> > > > >> > As I read the manuals one can have either a monotone or a realtime > timer. > > >> But I seem to need features of each. > > >> > > > >> > Specifically, I would like the daily timer to trigger 10 minutes > > >> > (say) after > > >> boot (OnBootSec=600) but not more than once a day (OnCalendar=daily). > > >> > The manual and several wiki pages suggest that you can't mix monotone > and > > >> realtime options. > > >> > > > >> > Am I misreading the manual (and mixing is permitted) or is there a way > to > > >> achieve my goals with just monotone or just realtime options. > > >> > > >> I think so, this is what systemd.timer(5) says: > > >> > > >> Multiple directives may be combined of the same and of different types. > For > > >> example, by > > >> combining OnBootSec= and OnUnitActiveSec=, it is possible to define a > timer > > >> that elapses in > > >> regular intervals and activates a specific service each time. > > >> > > >> There's also sys-process/systemd-cron that works like a regular cron > > >> and seems > > >> to work fine for me but I haven't tested it depth. > > > > > > Right, I have one timer that, for example, uses: > > > > > > [Timer] > > > OnBootSec=10m > > > OnUnitInactiveSec=1h > > > > Those are both monotone options so definitely can be combined. > > > > I want daily so would have > > > > [Timer] > > OnBootSec=10 minutes > > OnUnitInactiveSec=1d > > > > However If I boot the machine at 9am, turn it off at 10am, > > and boot again at 11am, won't the timer fire twice? I thought for > > monotone timers the time starts anew a the next boot? > > > > thanks, > > allan > > > > Sorry I'm not sure, it says the semantics are the same so I assume that means > they can be mixed but I'm unclear if they run twice in that case. I guess you > can just set it to a short interval, wait for it to run, then reboot and see > what happens (and let us know the result :). I'm curious about it, too. > If you use OnCalendar with > Persistent=true it should run no more than once a day though, but it'll run > right away on boot if you miss it one day. The persistent daily timers I have *will* run twice on one day if you missed one or more deadlines. They will run once for all the missed deadlines, then continue on the next deadline as usual. I don't use the "daily" keyword, but that is equivalent to "*-*-* 00:00:00", whereas my timers are "*-*-* 23:00", so I expect "daily" to behave the same. > If you just want to replace cron my advice is install systemd-cron, it has > the > advantage that it'll satisfy any dependencies on cron. If you don't want to > install it you can still download it and see how they did it. I agree, I switched to it pretty much the instant it was in the portage tree. However, I don't have any self-defined cron jobs, only those installed by packages into /etc/cron.daily/. I use timer units directly for my own repeating jobs. -- Marc Joliet -- "People who think they know everything really annoy those of us who know we don't" - Bjarne Stroustrup
pgpiNr6OX5fEb.pgp
Description: Digitale Signatur von OpenPGP