[systemd-devel] what is the best way to connect to another user's service (when root)?
Jeff Solomon
jsolomon8080 at gmail.com
Fri Nov 24 06:56:34 UTC 2017
Hi,
More questions about the systemd user service.
Inside a script running as root, I want to control another user's service.
I have found two ways to do this:
systemd-run -t --setenv=XDG_RUNTIME_DIR=/run/user/<uid> --uid=<uid>
systemctl --user ...
or:
su -l <username> -c "XDG_RUNTIME_DIR=/run/user/<uid> systemctl --user
..."
Both work.
If there a better way to do this?
My distros aren't recent enough to include "machinectl shell" but is that
the recommended way now?
machinectl --uid=<uid> shell /bin/systemctl --user ...
Perhaps there is not enough demand to justify it, but I would love if the
systemctl command itself had a way to specify that it should communicate
with a different user's service rather than system service or the calling
user's service. Something like:
systemctl --uid=<uid> --user ..
would be awesome.
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20171123/5b316297/attachment.html>
More information about the systemd-devel
mailing list