본문 바로가기

IT/Linux

[centos] linux 메모리 확인

간단히 보기(ps -ef)

ps -ef --sort -rss
실행예시
[root@jmnote ~]# ps -ef --sort -rss
UID        PID  PPID  C STIME TTY          TIME CMD
mysql     1154  1064 99 May03 ?        213287-12:54:30 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --l
apache   26245  1202  0 03:48 ?        00:00:05 /usr/sbin/httpd
apache   26247  1202  0 03:48 ?        00:00:07 /usr/sbin/httpd
... (생략)
root       741     2  0 May03 ?        00:00:00 [kmpath_handlerd]
root       768     2  0 May03 ?        00:00:00 [kjournald]

→ /usr/libexec/mysqld 프로세스가 물리 메모리를 가장 많이 점유하고 있다.

상위 10개

명령어
ps -ef --sort -rss | head -n 11

메모리 사용량 표시 (ps -eo)

명령어
ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,cmd --sort -rss | head -n 11
실행 예시
[root@jmnote ~]# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,cmd --sort -rss | head -n 11
USER       PID  PPID   RSS    SZ    VSZ %MEM %CPU     TIME CMD
mysql     1154  1064 26116 582252 642724  4.8 6623646 213287-12:54:31 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
apache   26245  1202 24284 18320 347196  4.5  0.0 00:00:05 /usr/sbin/httpd
apache   26247  1202 23780 17824 346700  4.4  0.0 00:00:07 /usr/sbin/httpd
apache   26248  1202 23632 17048 345924  4.4  0.0 00:00:05 /usr/sbin/httpd
apache   26242  1202 23112 18080 342768  4.3  0.0 00:00:06 /usr/sbin/httpd
apache   26249  1202 23100 18076 342764  4.3  0.0 00:00:06 /usr/sbin/httpd
apache   26692  1202 23084 18084 342772  4.3  0.0 00:00:03 /usr/sbin/httpd
apache   26244  1202 22844 17828 342516  4.2  0.0 00:00:06 /usr/sbin/httpd
apache   26243  1202 22832 17828 342516  4.2  0.0 00:00:08 /usr/sbin/httpd
apache   26693  1202 22832 17820 342508  4.2  0.0 00:00:04 /usr/sbin/httpd

→ /usr/libexec/mysqld 프로세스가 물리 메모리를 가장 많이 점유하고 있으며 그 용량은 26116KB이다.

명령인수 숨기기

프로세스 수행명령어에서 인수부분을 표시하지 않으려면 cmd를 comm으로 변경하면 된다.

명령어
ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11
실행 예시
[root@jmnote ~]# ps -eo user,pid,ppid,rss,size,vsize,pmem,pcpu,time,comm --sort -rss | head -n 11
USER       PID  PPID   RSS    SZ    VSZ %MEM %CPU     TIME COMMAND
mysql     1154  1064 26116 582252 642724  4.8 6624384 213287-12:54:31 mysqld
apache   26245  1202 24284 18320 347196  4.5  0.0 00:00:05 httpd
apache   26247  1202 23780 17824 346700  4.4  0.0 00:00:07 httpd
apache   26248  1202 23632 17048 345924  4.4  0.0 00:00:05 httpd
apache   26242  1202 23112 18080 342768  4.3  0.0 00:00:06 httpd
apache   26249  1202 23100 18076 342764  4.3  0.0 00:00:06 httpd
apache   26692  1202 23084 18084 342772  4.3  0.0 00:00:03 httpd
apache   26244  1202 22844 17828 342516  4.2  0.0 00:00:06 httpd
apache   26243  1202 22832 17828 342516  4.2  0.0 00:00:08 httpd
apache   26693  1202 22832 17820 342508  4.2  0.0 00:00:04 httpd

출처 : http://jmnote.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EB%A9%94%EB%AA%A8%EB%A6%AC_%EC%82%AC%EC%9A%A9%EB%A5%A0_%ED%99%95%EC%9D%B8