我可以透過systemctl命令找到哪個用戶正在運行服務嗎?

我可以透過systemctl命令找到哪個用戶正在運行服務嗎?

我想弄清楚哪個用戶正在使用給定的服務。systemctl status似乎沒有提供該信息

sudo systemctl status nginx.service
sudo systemctl status emperor.uwsgi.service
● emperor.uwsgi.service - uWSGI Emperor
   Loaded: loaded (/etc/systemd/system/emperor.uwsgi.service; disabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Tue 2020-03-31 11:26:34 UTC; 7min ago
  Process: 31133 ExecStart=/usr/local/bin/pipenv run uwsgi --ini uwsgi.ini (code=exited, status=1/FAILURE)
 Main PID: 31133 (code=exited, status=1/FAILURE)

Mar 31 11:26:34 ip-10-28-34-70.eu-west-1.compute.internal systemd[1]: emperor.uwsgi.service: main process exited, code=exited, status=1/FAILURE
Mar 31 11:26:34 ip-10-28-34-70.eu-west-1.compute.internal systemd[1]: Failed to start uWSGI Emperor.

有什麼方法可以從中獲取此資訊systemctl或我需要打開單元文件嗎?

答案1

您可以systemctl show為此使用:

systemctl show -pUser,UID nginx

如果User什麼也不顯示,且UID[not set],則服務正在以 root 身分運行,或在使用者服務的情況下以所有者使用者身分執行。

相關內容