[systemd-devel] Is there a way to see if a script is run from systemd
Kai Krakow
hurikhan77 at gmail.com
Sun May 8 16:47:49 UTC 2016
Am Sun, 8 May 2016 13:05:34 +0200
schrieb Reindl Harald <h.reindl at thelounge.net>:
> Am 07.05.2016 um 15:00 schrieb Cecil Westerhof:
> > I have written a Bash script to be used for a service. Is it
> > possible to see in the script if it is run from systemd? I could
> > use this for debugging purposes
>
> just set a environment variable in the systemd unit or check against
> a lot of env-vars missing which are there in a ordinary shell but
> removed from systemd to start with a clean anvironement
Probably it would also work to look at $PPID which should be 1 if
running under systemd - I have not tried that, tho.
But keep in mind that this may not be systemd-specific. And, if you
daemonize, the parent may switch to 1.
--
Regards,
Kai
Replies to list-only preferred.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digitale Signatur von OpenPGP
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160508/b536842c/attachment.sig>
More information about the systemd-devel
mailing list