<div dir="ltr">Hi folks,<div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>First of all thanks for all good answers. After looking deep how the "ps" command gets the unit name, I found out that it uses function "sd_pid_get_unit" from</div><div>systemd/sd-login.h in libsystemd.so. So I decide to use it as well. Thanks a lot.<br></div><div><br></div></blockquote>Best wishes,</div><div>Kevin</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-12-21 23:05 GMT+08:00 Tomasz Torcz 👁️ <span dir="ltr"><<a href="mailto:tomek@pipebreaker.pl" target="_blank">tomek@pipebreaker.pl</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Dec 21, 2017 at 01:48:29PM +0800, Kevin Hsu wrote:<br>
> Hi folks,<br>
><br>
> I am looking for a good way to backtrace systemd service by a process id.<br>
> The "systemctl status <pid>" command is available to do the magic. It will<br>
> show a full status of the service that creates the<br>
> pid. But this command gives too many details. The only thing I need is the<br>
> service unit name. Is there any simple way instead of parsing results from<br>
> "systemctl status" ?<br>
><br>
> For example like<br>
><br>
> > systemctl service-get 5566<br>
> > nginx.service<br>
<br>
<br>
</span> Look into /proc/<pid>/cgroup<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Tomasz Torcz Once you've read the dictionary,<br>
xmpp: <a href="mailto:zdzichubg@chrome.pl">zdzichubg@chrome.pl</a> every other book is just a remix.<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.<wbr>freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/systemd-devel</a><br>
</div></div></blockquote></div><br></div>