查看內存佔用
-
free -m/-h/-t/-s 5/
-
查看某個pid的物理內存使用情況
cat /proc/PID/status | grep VmRSS
查看pid
pidof nginx
- 查看本機所有進程的內存佔比之和
ps auxw|awk '{if (NR>1){print $4}}' > /opt/mem_list
awk '{MEM_PER+=$1}END{print MEM_PER}' /opt/mem_list
查看CPU使用情況
- top
top -d 5
- ps auxw(查看本機的進程所佔cpu和mem的百分比情況)
- 查看本機所有進程的CPU佔比之和
ps auxw|awk '{if (NR>1){print $3}}' > /opt/cpu_list
awk '{CPU_PER+=$1}END{print CPU_PER}' /opt/cpu_list
查看cpu信息
- 查看虛擬機邏輯CPU的個數
cat /proc/cpuinfo| grep "processor"| wc -l
- 查看物理CPU個數
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
- 列出CPU詳細信息
lscpu
- 查看每個物理CPU中core的個數(即核數)
cat /proc/cpuinfo| grep "cpu cores"| uniq
Linux下查看哪些進程佔用的CPU和內存資源最多的方法
- 獲取佔用CPU資源最多的10個進程
ps aux | head -1; ps aux | grep -v PID | sort -rn -k +3 | head -10
- 獲取佔用內存資源最多的10個進程
ps aux | head -1; ps aux | grep -v PID | sort -rn -k +4 | head -10
- 查看某一服務的啓動時間、運行時間。
ps -eo pid,lstart,etime,cmd|grep nginx