linux 查看内存占用如何查看当前占用CPU或内存最多的K个进程

匿名用户不能发表回复!|按列 sort 排序
Linux 如何查看当前占用CPU或内存最多的K个进程 - mdong - 博客园
遵循美德行事,纵使没有增加快乐,也可减轻焦虑。
posts - 173, comments - 0, trackbacks - 0, articles - 0
用法:sort [选项]... [文件]...Write sorted concatenation of all FILE(s) to standard output.
长选项必须用的参数在使用短选项时也是必须的。顺序选项:
-b, --ignore-leading-blanks
ignore leading blanks
-d, --dictionary-order
consider only blanks and alphanumeric characters
-f, --ignore-case
fold lower case to upper case characters
-g, --general-numeric-sort
compare according to general numerical value
-i, --ignore-nonprinting
consider only printable characters
-M, --month-sort
compare (unknown) & `JAN' & ... & `DEC'
-n, --numeric-sort
compare according to string numerical value
-r, --reverse
reverse the result of comparisons
Other options:
-c, --check
check whe do not sort
-k, --key=POS1[,POS2]
start a key at POS1, end it at POS2 (origin 1)
-m, --merge
do not sort
-o, --output=FILE
write result to FILE instead of standard output
-s, --stable
stabilize sort by disabling last-resort comparison
-S, --buffer-size=SIZE
use SIZE for main memory buffer
-t, --field-separator=SEP
use SEP instead of non-blank to blank transition
-T, --temporary-directory=DIR
use DIR for temporaries, not $TMPDIR or /
multiple options specify multiple directories
-u, --unique
with -c, check
without -c, output only the first of an equal run
-z, --zero-terminated
end lines with 0 byte, not newline
显示此帮助信息并退出
输出版本信息并退出
ps aux|sort -k3nr|grep "^resin" |head -2
sort -t &选项可以手工指定分隔符号
--------------------------------------------
[test@linux]$ cat aa3 51 13 2[test@linux]$ cat aa|sort -k2 & & &2指第2列1 13 23 5[test@linux]$ cat aa|sort -k2r & & r 倒序 reverse3 53 21 1[test@linux]$ cat aa|sort -k1r & & 1指第一列3 53 21 1[test@linux]$ cat aa|sort -k11 13 23 5今天登陆同事的一台gateway 开始以为hive环境登陆不了了,仔细一看看了下是因为机器很卡,我每次等几秒没登陆就ctrl+c了,看了下是有个java进程cpu:340.4%& mem:14.6%
一般解决方法是通过top命令找出消耗资源高的线程id,利用strace命令查看该线程所有系统调用
1. 通过top命令找到可疑进程PID
top 一下
可以看出java进程CPU利用率一直保持100%,稳居不下,找到PID 24138
2. 找出消耗资源最高的线程
top -H -p& 29580& 可以不用第一步,直接执行命令 top -H ,就可以查看到消耗资源最高的线程
top - 20:42:01 up 633 days,& 9:30,& 9 users,& load average: 6.75, 8.32, 15.86
Tasks:& 28 total,&& 2 running,& 26 sleeping,&& 0 stopped,&& 0 zombie
Cpu(s): 42.4%us,& 4.3%sy,& 0.0%ni, 53.1%id,& 0.0%wa,& 0.0%hi,& 0.1%si,& 0.1%st
Mem:&& 7680000k total,& 5774940k used,& 1905060k free,&& 400792k buffers
Swap:& 2096472k total,&& 876580k used,& 1219892k free,& 1727652k cached
& PID USER&&&&& PR& NI& VIRT& RES& SHR S %CPU %MEM&&& TIME+& COMMAND&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
29679 baishou&& 16&& 0 g& 18m R 72.0 15.3 115:41.08 java&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
29678 baishou&& 15&& 0 g& 18m R 63.3 15.3 118:44.99 java&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
29673 baishou&& 15&& 0 g& 18m S& 1.0 15.3&& 0:59.72 java&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
29677 baishou&& 15&& 0 g& 18m S& 1.0 15.3&& 1:01.34 java&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
3. 查看这个线程所有系统调用
strace -p 29679
read(114, "\0\225\0\0\6\0\0\0\0\0\10\0\0\4\3\0\0\0p\365\1_\0\0\0\0\0\0\0\0\0\4"..., 2064) = 149
write(114, "\7\333\0\0\6\0\0\0\0\0\3\201r\4\0\0\0\0\0\0\0 B\25\274\252*\0\0\275.\0"..., 2011) = 2011
write(114, "\7\333\0\0\6\0\0\0\0\0Adddddc\2\301!\4\302dQQ\3\300R\37\3\300c"..., 2011) = 2011
write(114, "\7\333\0\0\6\0\0\0\0\\6\1JdK\ttb0\1\200"..., 2011) = 2011
write(114, "\7\333\0\0\6\0\0\0\0\\6\1K6\27\ttb0\1\200"..., 2011) = 2011
write(114, "\7\333\0\0\6\0\0\0\0\0&\0|0\6\305\6\1L\23\20\ttb"..., 2011) = 2011
write(114, "\7\333\0\0\6\0\0\0\0\0\\1\200\2\301)\1\200\2\301\2\1\200\1\200\1\200\1\200"..., 2011) = 2011
write(114, "\0\34\0\0\6\0\0\0\0\0\200\1\200\1\200\1\200\n\300\31\20F\10\27#\23\23)", 28) = 28
read(114, "\0\225\0\0\6\0\0\0\0\0\10\0\0\4\3\0\0\0q\365\1_\0\0\0\0\0\0\0\0\0\4"..., 2064) = 149
write(114, "\7\333\0\0\6\0\0\0\0\0\3\201s\4\0\0\0\0\0\0\0 B\25\274\252*\0\0\311.\0"..., 2011) = 2011
发现有大量写操作,应该是由datax任务在跑。
+++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++如果是web应用,可以继续打印线程的堆栈信息+++++++++
将需要的线程ID转换为16进制格式:
printf "%x\n" 29679
73ef
最后打印线程的堆栈信息:
jstack 29679|grep 73ef -A 30
参考:http://blog.csdn.net/delphiwcdj/article/details/7387325
浏览: 173779 次
来自: 杭州
学习了。http://surenpi.com
String[] tools = StringUtils. ...
请问这种情况下python脚本里面怎么打counter呢?通常 ...
print '\t'.join([foo, strmap])+ ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'博客访问: 653704
博文数量: 550
注册时间:
高阳电话 邮箱,QQ群:
ITPUB论坛APP
ITPUB论坛APP
APP发帖 享双倍积分
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: Linux
原文地址: 作者:
linux下获取占用CPU资源最多的10个进程,可以使用如下命令组合:&
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
linux下获取占用内存资源最多的10个进程,可以使用如下命令组合:&
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
命令组合解析(针对CPU的,MEN也同样道理):&
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
该命令组合实际上是下面两句命令:&
ps aux|head -1 ps aux|grep -v PID|sort -rn -k +3|head
阅读(37) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。2012年9月 Linux/Unix社区大版内专家分月排行榜第二2012年7月 Linux/Unix社区大版内专家分月排行榜第二
2012年6月 Linux/Unix社区大版内专家分月排行榜第三2009年4月 硬件/嵌入开发大版内专家分月排行榜第三
2012年9月 Linux/Unix社区大版内专家分月排行榜第二2012年7月 Linux/Unix社区大版内专家分月排行榜第二
2012年6月 Linux/Unix社区大版内专家分月排行榜第三2009年4月 硬件/嵌入开发大版内专家分月排行榜第三
2013年6月 Linux/Unix社区大版内专家分月排行榜第二2013年5月 Linux/Unix社区大版内专家分月排行榜第二2013年3月 Linux/Unix社区大版内专家分月排行榜第二2013年1月 Linux/Unix社区大版内专家分月排行榜第二2012年12月 Linux/Unix社区大版内专家分月排行榜第二2012年8月 Linux/Unix社区大版内专家分月排行榜第二2011年12月 Linux/Unix社区大版内专家分月排行榜第二2011年10月 C/C++大版内专家分月排行榜第二2011年10月 Linux/Unix社区大版内专家分月排行榜第二
2012年6月 C/C++大版内专家分月排行榜第三2012年6月 PHP大版内专家分月排行榜第三2012年5月 C/C++大版内专家分月排行榜第三2012年3月 Linux/Unix社区大版内专家分月排行榜第三2012年2月 Linux/Unix社区大版内专家分月排行榜第三2011年11月 C/C++大版内专家分月排行榜第三
匿名用户不能发表回复!|

我要回帖

更多关于 查看进程占用多少内存 的文章

 

随机推荐