2019年3月10日 星期日

[Linux 文章收集] Check Top Processes sorted by RAM or CPU Usage in Linux

Source From Here 
Preface 
The following command will show the list of top processes ordered by RAM and CPU use in descendant form (remove the pipeline and head if you want to see the full list): 
# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

Sample Output: 
 

Brief explanation of above options used in above command. 

The -o (or –format) option of ps allows you to specify the output format. A favorite of mine is to show the processes’ PIDs (pid), PPIDs (pid), the name of the executable file associated with the process (cmd), and the RAM and CPU utilization (%mem and %cpu, respectively). 

Additionally, I use --sort to sort by either %mem or %cpu. By default, the output will be sorted in ascendant form, but personally I prefer to reverse that order by adding a minus sign in front of the sort criteria. To add other fields to the output, or change the sort criteria, refer to the OUTPUT FORMAT CONTROL section in the man page of ps command. 

Supplement 
* Linux 用 ps 與 top 指令找出最耗費 CPU 與記憶體資源的程式 
這裡介紹如何在 Linux 中使用 ps 與 top 指令列出系統上最吃 CPU 與記憶體的程式。作為 Linux 系統的管理者,時常都需要查看系統的負載狀況,如果系統中出現不正常的程式,吃掉太多的 CPU 或記憶體資源,就會影響系統的效能,太嚴重的話甚至會造成當機等狀況。


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...