[systemd-devel] Deferring start of service until file exists

Colin Hogben systemd at pythontech.co.uk
Mon Aug 19 12:29:17 UTC 2019


Hi,
(Hoping this is an appropriate place to ask this question...)

During system start-up, I want to defer starting a unit (a service)
until a particular file is written (amongst other dependencies).  In
my case I am writing the service's configuration file within a
dhclient hook script.

Any guidance on achieving this with systemd would be much appreciated.

I don't think a .path unit is the appropriate tool for the job, since
AIUI that is intended to start a new systemd transaction rather than
for scheduling within an existing transaction.  I tried having my
service depend on (via Requires/After) the foo.unit related to
foo.path, but then systemd starts foo.unit straight away regardless of
foo.path.  If I have After=foo.unit and Requires=foo.path, then it seems 
like foo.unit is not "pulled in", and the After has no effect.  But 
maybe I missed something.

The .path causes its related unit to start, whereas I think I want to
provoke a transition in a unit from startING to startED - am I right?

I thought of using the 'inotify' executable within a unit upon which
my service could depend.  Unfortunately, CentOS (& Redhat) in their
wisdom decided not to package inotify-tools.

Thanks for any help,
-- 
Colin Hogben


More information about the systemd-devel mailing list