gpt4 book ai didi

linux - 查看所有机器上给定用户的进程

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:54:50 26 4
gpt4 key购买 nike

在具有不同计算机的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com