[systemd-devel] what to depend on to avoid file mtime discontinuities?
Colin Guthrie
gmane at colin.guthr.ie
Tue Mar 19 03:17:53 PDT 2013
'Twas brillig, and Britton Kerin at 18/03/13 17:56 did gyre and gimble:
> My service needs reasonably continuous mtimes on files, but at the
> moment there is a big discontinuity soon after boot.
There is nothing you can do to rely on this absolutely. The only proper
way is to fix the broken assumptions. Of course you can typically get a
"good enough" result (tho' that doesn't make it any more correct,
especially twice a year when daylight savings kicks in unless you're on
a fixed timezone).
> There are a number of web pages out there which tell you to put
> stuff like this:
>
> After=syslog.target network.target
> WantedBy=multi-user.target
So this is written somewhat confusingly as these two directives go in
different sections [Unit] and [Install] respectively.
syslog.target is dead now so you don't need it any longer with any
vaguely recent system.
network.target is a bit rubbish too as the network is not really a
static entity - it can appear to be 99.9% static.
network itself has nothing to do with time.
> In your .service file linked from:
>
> /etc/systemd/system/multi-user.target.wants
>
> I'm guess I want to be After one of these targets:
>
> time-sync.target or
> systemd-timedated.service
Yes, time-sync.target seems best.
It's not a guarantee tho'. If there are network issues etc. then
time-sync.target will be reached after a timeout if ntp tries and fails
to update itself over the network. If the problem rectifies itself later
(and this could be e.g. a routing issue totally outside of your server),
then the ntp server should try and fix things. Of course most sensible
ntp targets try to avoid big jumps and slow or speed the clock up a bit
to bring it in line (please correct me if I'm wrong).
> But if multi-user.target doesn't already depend on them I'm not sure its
> safe for my target, which is WantedBy multi-user.target, to do so?
You are confusing After and WantedBy here. The former is about ordering,
the latter is about about grouping.
WantedBy just means "I want this service to be started when
multi-user.target starts" It doesn't contain any information about
ordering etc. In an ideal world, everything wanted by multi-user.target
would all be started in parallel. In practice, we typically want some
degree of ordering, and that's what the Before= and After= directives
are about.
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited http://www.tribalogic.net/
Open Source:
Mageia Contributor http://www.mageia.org/
PulseAudio Hacker http://www.pulseaudio.org/
Trac Hacker http://trac.edgewall.org/
More information about the systemd-devel
mailing list