The following command looks at the list of top processes in descending order of RAM and CPU:
[[Email protected]~]# Ps-eo PID,PPID,CMD,%MEM,%CPU--sort=-%mem | HeadPID PPID CMD%Mem%Cpu1 0 /Sbin/Init0.1 0.0 2 0 [Kthreadd] 0.0 0.0 3 2 [Migration/0] 0.0 0.0 4 2 [Ksoftirqd/0] 0.0 0.0 5 2 [Stopper/0] 0.0 0.0 6 2 [Watchdog/0] 0.0 0.0 7 2 [events/0 0.0 0.08 2 [ events/0] 0.0 0.0 9 2 [events_long/0] 0.0 Span class= "lit" >0.0
A brief explanation of the parameters of the commands used above
The PS-O (or–format) option lets you specify the output format, and my favorite is to show the process's PIDs (PID), Ppids (PID), and the name of the execution file associated with the process (CMD), as well as the RAM and CPU usage (respectively:%mem and%CPU).
Also, I usually use –sort to sort%mem and%cpu. By default, the output is sorted in ascending order. But personally, I prefer to add a minus sign before the sort command to reverse the order.
Add other fields to the output, or change the sorting criteria, refer to the Output Fromat CONTROL section of the PS Command's man page.
The monitoring process is one of the digital tasks of the Linux server administrator, and in this little knowledge, we learned how to list processes in your system and sort them in descending order by RAM and CPU by using the PS tool.
Reproduced: Original: http://www.centoscn.cn/2661.html
Find the most memory and CPU-efficient processes in Linux