博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Performing a thread dump in Linux or Windows--reference
阅读量:6075 次
发布时间:2019-06-20

本文共 3169 字,大约阅读时间需要 10 分钟。

Linux/Unix

1. Find the Java/Tomcat process id.

% ps ax | grep java

You should see output like this

17207 ?        Sl    78:36 /usr/java/default/bin/java -Djava.util.logging.config.file=/usr/tomcat/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xmx1024M -Xms128M -XX:MaxPermSize=256M -Djava.awt.headless=true -Djava.endorsed.dirs=/usr/tomcat/tomcat6/endorsed -classpath :/usr/tomcat/tomcat6/bin/bootstrap.jar -Dcatalina.base=/usr/tomcat/tomcat6 -Dcatalina.home=/usr/tomcat/tomcat6 -Djava.io.tmpdir=/usr/tomcat/tomcat6/temp org.apache.catalina.startup.Bootstrap start

2. Execute the following command to generate a thread dump

% kill -3 

Run this command every 5-10 seconds, 5 times.

3.The thread dump is written to the standard output.  It may logged in the console or <tomcat>/logs/stdout or <tomcat>/logs/catalina.out.

4. If you are running JDK 6.0+, you may also use jstack to produce a thread dump.

% jstack -l 
> threaddump.txt or % jstack
> threaddump.txt

Windows

Running as a Windows service

1a. If installed using Tomcat installer, click All Programs ->Apache Tomcat 6.0->Monitor Tomcat. An icon should appear in task bar.

apachemenu1.png

1b. If not installed using Tomcat installer, navigate to <tomcat>/bin, and run the following command

% tomcat7.exe //MS//Tomcat7

apacheicon.png

The Tomcat monitor icon should appear in the system tray.;

2. Right click the the icon and select Thread Dump.

Run this command every 5-10 seconds, 5 times

3. Look for the thread dump in  <tomcat>/logs/stdout or <tomcat>/logs/catalina.out.

 

Running from startup.bat

1. Open "Windows Task Manager",

2. Find the process ID of the java process

3. Make sure <JDK>/bin is in your command path. Otherwise, navigate to <JDK>/bin

4. Execute the following command to generate a thread dump

% jstack -l 
> threaddump.txt

Run this command every 5-10 seconds, 5 times

If you receive an error running jstack such as the below, then you may need to use psexec:

7988: Insufficient memory or insufficient privileges to attach The -F option can be used when the target process is not responding
 
1. Download psexec from  .
2. Unzip the 'PSTools' directory to a suitable place on your server.
3. Open a command prompt as Administrator and navigate to the location of the PSTools folder using the command prompt.
 
2014-09-08_1358.png
 
4. Open Task Manager > Services and find your Java (Tomcat) service and note down the PID number.
 
2014-09-09_1239.png

 

 5. At the command prompt type 'psexec -s [jdk path]\jstack.exe XXXX >> thread_dump_ddmmyy.log' (where XXXX is your PID and ddmmyy is the current date to append to the name of the log file) then hit enter. 
 
2014-09-09_1241.png
 

Run this command every 5-10 seconds, 5 times

You can also add the full path of your Java 'bin' directory to the server's system path variable. The Java 'bin' directory is usually in 'Program Files\Java\bin\jdk<version>\bin'.  If you add this path to the system variable then you will need to restart the command prompt again for the change to be picked up and the 'jstack' command to work.

reference from:
http://support.jamasoftware.com/entries/20535318-Performing-a-thread-dump-in-Linux-or-Windows

转载地址:http://ryxgx.baihongyu.com/

你可能感兴趣的文章
spring事务管理(Transaction)
查看>>
django.contrib.auth登陆注销学习
查看>>
js执行本地exe文件的3种方法
查看>>
理解B树索引
查看>>
vi编辑器的命令集合
查看>>
Mysql利用binlog恢复数据
查看>>
解决 Windows启动时要求验证
查看>>
我的友情链接
查看>>
用yum安装mariadb
查看>>
一点IT"边缘化"的人的思考
查看>>
Gallery循环滑动
查看>>
Sql与C#中日期格式转换总结
查看>>
iOS开发流程总结
查看>>
hadoop datanode 启动出错
查看>>
js颜色拾取器
查看>>
IDEA使用(1)intellIJ idea 配置 svn
查看>>
WPF 降低.net framework到4.0
查看>>
数据管理DMS 全量SQL诊断:你的SQL是健康的蓝色,还是危险的红色?
查看>>
搭建一个通用的脚手架
查看>>
开年巨制!千人千面回放技术让你“看到”Flutter用户侧问题
查看>>