我需要以用户的方式查看特定进程的计数。例如,我知道
ps -ef | grep apache这列出了所有apache进程。现在,我要统计一下每个用户在Linux中运行的进程数量。
我怎么能拿到这个。
发布于 2017-06-22 14:21:25
短期解决方案:
ps -eo "%U" --sort=user h | uniq -c--sort=user -按user name排序uniq -c -每个唯一用户的进程数发布于 2017-06-22 14:03:13
试一试
ps -e -o user h| awk '{u[$1]++} END { for (user in u ) printf "%s:%d\n",user,u[user]}'哪里
-e列表所有进程-o user只输出用户h不显示标头编辑:可以(某种程度上)缩短到,谢谢@Gohu。
ps -e -o user h| sort | uniq -c | sort -rg发布于 2017-06-22 14:34:57
POSIXly:
ps -Ao user= | sort | uniq -c | sort -rnhttps://unix.stackexchange.com/questions/372714
复制相似问题