加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

Performing a thread dump in Linux or Windows--reference

发布时间:2020-12-13 14:06:17 所属栏目:Linux 来源:网络整理
导读:Linux/Unix 1. Find the Java/Tomcat process id. You should see output like this 2. Execute the following command to generate a thread dump Run this command every 5-10 seconds,5 times. 3.The thread dump is written to the standard output.? It

Linux/Unix

1. Find the Java/Tomcat process id.

You should see output like this

2. Execute the following command to generate a thread dump

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 /logs/stdout or /logs/catalina.out.

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

> 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 /bin,and run the following command

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? /logs/stdout or /logs/catalina.out.

Running from startup.bat

1. Open "Windows Task Manager",

2. Find the process ID of the java process

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

4. Execute the following command to generate a thread dump

> 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:

?
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 FilesJavabinjdkbin'.? 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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读