Monday, October 25, 2021

[Linux] PS

[root@study ~]# ps aux  <==觀察系統所有的程序資料

[root@study ~]# ps -lA  <==也是能夠觀察所有系統的資料

[root@study ~]# ps axjf <==連同部分程序樹狀態


while true; do
ps -eo pid,ppid,cmd,%mem,%cpu --sort -pcpu,+pmem
ps -eo pid,ppid,%mem,%cpu --sort -pcpu,+pmem | awk '{if ($3!=0){total1 += $3;print "MEM:"$3"%";}} END { print "MEM:"total1"%" }'
ps -eo pid,ppid,%mem,%cpu --sort -pcpu,+pmem | awk '{if ($4!=0){total2 += $4;print "CPU:"$4"%";}} END { print "CPU:"total2"%" }'

sleep 3;
done&

當要刪除 while.... 

先查詢 pid
 PID TTY TIME CMD
15312 pts/84 00:00:00 ps
18095 pts/84 00:00:00 bash

 


kill -9 pid

Reference:

https://linux.cn/article-4743-1.html

https://blog.longwin.com.tw/2017/04/linux-ps-process-show-cpu-memory-2017/


No comments:

Post a Comment

n8n index

 【n8n免費本地端部署】Windows版|程式安裝x指令大補帖  【一鍵安裝 n8n】圖文教學,獲得無限額度自動化工具&限時免費升級企業版功能