查找Linux进程占用内存
查找Linux某些服务进程占用内存: 可通过服务名找到对应的进程PID,再根据PID查找内存占用
方法1:top
方法2:ps -aux | sort -k4nr | head -10
# ps -aux | sort -k4nr | head -10 polkitd 20177 0.0 4.7 1076676 89984 ? Ssl Jul09 6:35 mariadbd root 350 0.0 3.7 153944 70872 ? Ss 2021 20:43 /usr/lib/systemd/systemd-journald root 30961 0.0 2.4 1048828 46312 ? Ssl Apr10 18:45 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 977 0.0 2.2 741280 43120 ? Ssl 2021 22:53 /usr/sbin/rsyslogd -n root 12949 2.8 2.1 280784 41028 ? S<sl Jul10 807:56 /usr/local/aegis/aegis_client/aegis_11_33/AliYunDun polkitd 8808 0.0 1.7 98424 32020 ? S 09:13 0:07 php-fpm: pool www polkitd 10136 0.1 1.6 96440 31404 ? S 05:04 1:30 php-fpm: pool www root 8613 0.0 1.3 1089008 25820 ? Ssl 2021 68:16 /usr/bin/containerd root 840 0.0 0.7 574284 13208 ? Ssl 2021 35:39 /usr/bin/python2 -Es /usr/sbin/tuned -l -P polkitd 8795 0.0 0.6 76092 11520 ? S 09:12 0:06 php-fpm: pool www
方法3:按内存大小排序,打印出所有的进程
ps aux –sort -rss
# ps aux --sort -rss USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND polkitd 20177 0.0 4.7 1076676 89984 ? Ssl Jul09 6:35 mariadbd root 350 0.0 3.7 153944 70872 ? Ss 2021 20:43 /usr/lib/systemd/systemd-journald root 30961 0.0 2.4 1048828 46312 ? Ssl Apr10 18:45 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/cont root 977 0.0 2.2 741280 43120 ? Ssl 2021 22:53 /usr/sbin/rsyslogd -n root 12949 2.8 2.1 280784 41028 ? S<sl Jul10 807:57 /usr/local/aegis/aegis_client/aegis_11_33/AliYunDun polkitd 8808 0.0 1.7 98424 32020 ? S 09:13 0:07 php-fpm: pool www polkitd 10136 0.1 1.6 96440 31404 ? S 05:04 1:30 php-fpm: pool www root 8613 0.0 1.3 1089008 25820 ? Ssl 2021 68:16 /usr/bin/containerd root 840 0.0 0.7 574284 13208 ? Ssl 2021 35:39 /usr/bin/python2 -Es /usr/sbin/tuned -l -P polkitd 8795 0.0 0.6 76092 11520 ? S 09:12 0:06 php-fpm: pool www polkitd 516 0.0 0.4 612336 9140 ? Ssl 2021 0:45 /usr/lib/polkit-1/polkitd --no-debug root 32014 0.0 0.4 805636 7588 ? Ssl Jul21 9:56 /usr/local/share/aliyun-assist/2.2.3.315/aliyun-service root 27401 0.0 0.3 72816 7156 ? Ss Jul09 1:10 php-fpm: master process (/apps/php/etc/php-fpm.conf) root 20159 0.0 0.3 711688 6064 ? Sl Jul09 0:49 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 1e6e5c root 27351 0.0 0.3 711176 6036 ? Sl Jul09 0:47 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 8d0d22 root 2586 0.1 0.3 157592 5936 ? Ss 23:48 0:00 sshd: root@pts/2 root 2622 0.1 0.3 157592 5848 ? Ss 23:48 0:00 sshd: root@notty
原创文章,作者:745907710,如若转载,请注明出处:https://blog.ytso.com/277841.html