<div dir="ltr">Hi Folks,<br><br>I've posted a serverfault question [0], but it got no answers so I thought I'd bring it to the mailing list:<div><br></div><div>I have some systemd units installed and running. Let's say I manually uninstall foo.service by<br>

<br> - removing its .service (and .socket) files<br> - removing all symlinks (e.g from default.target.wants/)<br><br>I can run systemctl daemon-reload, and then I see:<br><br>    # systemctl status foo.service<br>    foo.service<br>

       Loaded: error (Reason: No such file or directory)<br>       Active: active (running) since Mon 2013-07-08 13:50:29 EST; 48s ago<br>     Main PID: 1642 (node)<br><br>So systemd knows that it's not installed, and that it is running. Is there some command I can use to stop all running services which no longer have a unit file?</div>

<div><br></div><div style>I do not want to have to somehow know what I've uninstalled, or for the command to work only in some circumstances - I want something that I can run at any point, with no additional knowledge, that will stop all units not backed by a unit file.</div>

<div><br>I've currently got a hacky script that:</div><div> - Runs `list-units` to get all unit names</div><div> - Then `show <span style="white-space:pre">-p </span>ActiveState -p UnitFileState $unit` on each</div><div>

 - It then runs `systemctl stop` on each unit with a UnitFileState of "" (empty string), and ActiveState of anything but "failed".</div><div><br></div><div>This is almost certainly missing some edge case, as I couldn't really find any documentation of these properties, it just seemed to be what occurred with the examples I encountered.<br>

</div><div><div><br></div><div>I'm hoping there's a better way, can anyone point me in the right direction?</div><div><br></div><div>[0]: <a href="http://serverfault.com/questions/521504/systemd-stop-all-uninstalled-units">http://serverfault.com/questions/521504/systemd-stop-all-uninstalled-units</a><br>

</div><div><br></div><div>Thanks, </div><div>- Tim Cuthbertson.<br><div><br></div></div></div></div>