<p>Am Montag, dem 30.06.2025 um 12:25 +0200 schrieb Stef Bon:</p>
<blockquote type="cite">
<p>Hi,</p>
<p>it's important for a program to detect it has been started by systemd.
For example it does not have to fork since it has already been forked.</p>
<p>I've written a test script, which calls env, and there are a few
unique environment variables which are an indication it has been
started by systemd: SYSTEMD_EXEC_PID and INVOCATION_ID.</p>
<p>Is it a good way to test these environment vars (to detect started by
systemd) or is there a better way?</p>
<p>S. Bon</p>
</blockquote>
<p>Hi,</p>
<p>to check if the system was booted with <code>systemd</code>, check the existence and return value of</p>
<pre><code>systemd-notify --booted
</code></pre>
<p>See <a href="man:systemd-notify(1)">man:systemd-notify(1)</a> for more information and some alternatives.</p>
<p>BR<br />
Silvio</p>