Script to get user that has process with most memory usage?

前端 未结 2 1764
执念已碎
执念已碎 2021-01-17 00:57

How can I write a script that gives an output of the user that has the process with the most memory usage in the system. The script is sh. I tried to use top command as the

2条回答
  •  误落风尘
    2021-01-17 01:40

    this works in centos: list most memory cost process

    [root@182 ~] # ps aux | sort -k 4 -r | head -n2
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root      7048  0.2  9.6 8060236 1573612 ?     Ssl  Dec14   8:23 java -Djava.security.e
    

    sort -k 4 : sort by the forth column, my pc column4 = %MEM

    in other linux/unix, you may find the right column number for memory

提交回复
热议问题