常用命令集

java统计服务线程状态

1
2
3
jstack <pid> > dump_pid.dump
grep "java.lang.Thread.State" dump_pid.dump | awk '{print $2$3$4$5}' | sort | uniq -c

查找大文件

1
find . -type f -size +200M -print0 | xargs -0 du -h | sort -nr

常用tcpdump头

1
tcpdump -i eth1 -XlAs0 -vnn 'dst port 8000'

清除大文件

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh
files=`find . -type f -size +200M -print0 | xargs -0 du -h | sort -nr
| awk '{print$2}'`
#echo $files
for i in $files;
do
echo $i
> $i;
done

查看进程占用

1
2
3
4
5
6
ps -p <pid> -L -o pcpu,pid,tid,time,tname,cmd
ps -p <pid> -Lf
watch -n 2 'ps -p 32270 -Lf'
watch -n 2 'ps -p 10948 -Lo pcpu,pid,tid,time,tname,cmd '

to be continued.