Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Bug in run-crons?
Date: Mon, 13 Dec 2021 21:54:54
Message-Id: CAGfcS_k0b46LqFwrjGd=Qbg2Mi9TyKtUGYfMMfuJvEcX0yxNqg@mail.gmail.com
In Reply to: Re: [gentoo-user] Bug in run-crons? by Michael Orlitzky
1 On Mon, Dec 13, 2021 at 4:42 PM Michael Orlitzky <mjo@g.o> wrote:
2 >
3 > On Mon, 2021-12-13 at 22:38 +0100, Frank Steinmetzger wrote:
4 > >
5 > > Well I *could* disable run-crons altogether and add entries to fcron’s own
6 > > crontab which would run those scripts in /etc/cron.{hourly,daily,...}
7 > > instead.
8 > >
9 > > However, I like predictable times at which those jobs will run. Especially
10 > > if one of them is a zfs scrub; the NAS is powered down for weeks, sometimes
11 > > months. And when I power it up, it’s for a reason. And that reason usually
12 > > is not a scrub, which—at the current zfs fill level—takes 10½ hours.
13 > >
14 >
15 > Why choose fcron then? It sounds like you have the same rationale as I
16 > do: "no, I don't want to run the 4am backup job in the middle of the
17 > business day just because it wasn't run at 4am."
18 >
19 > If you pick a dumber cron, the crontab entries are run only at the
20 > specified times.
21
22 There really are no one-size-fits all solutions obviously. You can
23 either have predictable times and if the machine is down things get
24 skipped, or you can run opportunistically in which case you lose
25 predictable times at least until the machine goes back to running
26 24x7. The machine has no way to know if you'll leave it on overnight
27 the NEXT night - only if you did so the one before.
28
29 fcron is perfectly capable of running jobs at either set times or at
30 loosely-defined intervals that are compensated for if the machine is
31 off. Systemd timers can also be set that way, and can also have
32 limits put on scheduling (daily nominally at 3AM but allowed between
33 11PM and 5AM or whatever). Obviously the more expressive the crontab
34 equivalent is, the more you can tweak it to do what you want it to.
35
36 The default configs are a one-size-fits all approach that tend to do
37 the right thing if you leave the machine on 24x7, or if you run it at
38 random times. If you want to specify exact behavior just edit the
39 config files and make it do so.
40
41 I'll also note that zfs scrubs checkpoint at shutdown and will
42 auto-resume where you leave off. If they are involved multiple times
43 with the default options I think any attempt to scrub something that
44 is already being scrubbed is just a no-op. Obviously if you don't
45 want all that IO during the day you'll have to do something more
46 clever - you can instruct it to pause and resume so you could have a
47 couple of crontab entries and scripts to do just that.
48
49 --
50 Rich

Replies

Subject Author
Re: [gentoo-user] Bug in run-crons? Frank Steinmetzger <Warp_7@×××.de>