在具有不同计算机的 linux 服务器上:有没有办法查看所有计算机上给定用户运行的所有进程?
最佳答案
也许现在回答为时已晚,但对于记录...
您可以通过以下方式获取:
hosts='192.168.1.x 192.168.1.y' # your hosts here
for host in $hosts; do
echo $host:
ssh some_user@$host 'ps -u given_user' # some_user for ssh, given_user for ps
done
通过这种方式,您将创建一个 ssh
每个主机的 session :
ssh ... [user@]hostname [command]
If command is specified, command is executed on the remote host instead of a login shell.
...并执行 ps
使用 -u
选项:
-u userlist
Select by effective user ID (EUID) or name.
This selects the processes whose effective user name or ID is in userlist.
关于linux - 查看所有机器上给定用户的进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27067900/