常用命令总结

0

jps:查看当前Java进程

jstack pid:查看Java进程的线程快照

jmap -histo:live pid:查看Java进程的内存快照

内存快照时间统计

cat file |grep cpu=|grep -Po '(cpu=\d+\.\d+ms)'|grep -Po '(\d+\.\d+)'|awk '{sum += $1}END{print sum}'

关闭JIT

-Djava.compiler=NONE

提交Sonar

mvn sonar:sonar -D "sonar.projectKey=snail" -D "sonar.host.url=http://localhost:9000" -D "sonar.login=token"

消息分类统计

cat snail.log.*|grep -a 处理piece消息|grep TCP|wc -l;cat snail.log.*|grep -a 处理piece消息|grep UTP|wc -l;cat snail.log.*|grep -a 发送piece消息|grep TCP|wc -l;cat snail.log.*|grep -a 发送piece消息|grep UTP|wc -l;

异常分类统计

cat snail.log.* | grep -a Exception | sort | uniq -c | sort

批量查询替换

sed -i "s/查找内容/替换内容/g" `grep -rl "查找内容" ./`

统计日志输出

cat debug.log | grep ' DEBUG ' | awk '{print $5}' | sort | uniq -c | sort

mongo命令

启动:./mongod --config ../conf/config.conf -dbpath ../data
关闭:./mongod --shutdown --dbpath ../data
备份:/home/mongo/bin/mongodump -h localhost -d acgist_nlp -u admin -p password -o /home/backuptmp/acgist.nlp.mongodb.backup