[systemd-devel] Quick ? about ExecStartPre and Restart

Reindl Harald h.reindl at thelounge.net
Wed Jul 3 16:06:32 PDT 2013

Am 04.07.2013 00:38, schrieb Paul D. DeRocco:
> I'm new to systemd, and I'm confused about something. The docs include the
> following sentence under the Restart directive:
> "Configures whether the service shall be restarted when the service process
> exits, is killed, or a timeout is reached. The service process may be the
> main service process, but also one of the processes specified with
> ExecStartPre=, ExecStartPost=, ExecStopPre=, ExecStopPost=, or ExecReload=."
> Read literally, this suggests that if I set this to "on-success" or
> "always", and I have an ExecStartPre that runs a quick command (in my case,
> to copy my main service executable from a flash drive to a RAM drive), then
> as soon as that completes, systemd will say, "Hey, the service has
> terminated, time to restart it" and never get around to the ExecStart that
> really does the work.
> Is that really true? Or is that just a mistake in the docs? If it's not a
> mistake, how do I configure it so that it won't restart when the command
> launched by ExecStartPre terminates with a 0 exit code, but will restart if
> the actual service started by ExecStart terminates with a 0 exit code?

it is not true and the documentation ha sno mistake

systemd does *not* consider the service as failed if ExecStartPre
terminates with a clean 0 exit code - it is considered as failed
if the ExecStartPre command does return a *non zero* code and
even that can be avoided with ExecStartPre=-/path/to/bin as the
doc states

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130704/7fccefd4/attachment.pgp>

More information about the systemd-devel mailing list