1. 生成快照:
命令:jmap -dump:format=b,file=yourself_file_name.hprof pid
实例:jmap -dump:format=b,file=2021-06-27-01.hprof 20945
2. 压缩成 zip 文件
命令:zip -r -q dest_file_name src_file_name (-r: 循环子文件夹及文件、-q 隐藏压缩过程)
实例:zip -r -q 2021-06-27-01.hprof.zip 2021-06-27-01.hprof
3. tar 解压缩 与 解压缩
命令:压缩 tar -cxvf file_name 、解压缩 tar -zxvf file_name
4. 查询匹配行数:
命令:grep -c 'key' file_name.log
实例:grep -c '任务执行开始——' hm-info.log
扩展:grep -A 100 'key' file_name.log 查询定位key行及其后100行;grep -B 100 'key' file_name.log 之前;grep -C 100 'key' file_name.log 前后各100行。
5. 查询时间区间内,指定关键字的匹配记录
命令:
实例:sed -n '/2021-04-28 21:08:22,311:INFO/,/2021-04-28 21:32:06,682:INFO/p' info-2021-04-28.log | grep 'ConsumeMessageThread_13'
6.查询进程pid
命令:ps -ef|grep key
实例:ps -ef|grep engine
7.查询指定进程内线程数:
命令:pstree -p pid | wc -l
实例:pstree -p 28212 | wc -l
8.查询指定进程的线程的详细信息
命令:top -H -p pid
实例:top -H -p 28212