JPS Introduction and Resolution JPS unable to view a startup Java process issue "misappropriation"

Source: Internet
Author: User
Tags jconsole

1, the role of JPS

JPS similar to the Linux PS command, the difference is that PS is used to display the process, and JPS only shows the Java process, is exactly the current user started part of the Java process information, including the process number and the short process command.

2, a Java process has been started, with JPS but the process number is not displayed

This question has been met twice, so here's a summary.

Phenomenon:

with Ps-ef|grep Java you can see the startup Java process, but the ID of the process does not exist with JPS view. We'll know later. In this case,Jconsole, JVISUALVM may not be able to monitor the process, and other Java-brought tools may not be available

Analysis:

When the Java program starts, the default (note default) creates a new file in the /tmp/hsperfdata_username directory with the process ID as the filename , and stores information about the JVM's run in that file . The username is the current user name, and the/tmp/hsperfdata_username directory holds all the Java process information that the user has started. For Windows machine/tmp, use Windows to store temporary file directories instead.

The data source for tools such as JPS, Jconsole, and JVISUALVM is this file (/tmp/hsperfdata_username/pid). So when the file does not exist or cannot be read, it will appear JPS cannot view the process number, Jconsole cannot monitor the problem

Reason:

(1), disk read and write, directory permissions issues

If the user does not have permission to write the/tmp directory or the disk is full, the /tmp/hsperfdata_username/pid file cannot be created. Or the file has been generated, but the user does not have Read permission

(2), Temporary files are lost, deleted or cleaned regularly

For Linux machines, there is usually a scheduled task to clean up the temporary folder, causing the/tmp directory to be emptied. This is the first time I have encountered the cause of the phenomenon. Common tools that may periodically delete temporary directories are crontab, Redhat Tmpwatch, Ubuntu Tmpreaper, and so on.

The resulting phenomenon may be that, using Jconsole to monitor the process, it is found that the process still exists after a certain period of time, but there is no monitoring information.

(3),Java process information file storage address is set, not IN/tmp directory

We said in the above that the default is to save the process information in the /tmp/hsperfdata_username directory , but because of the reasons mentioned above 1, 2, may cause the file can not be generated or lost, so Java started with parameters (- Djava.io.tmpdir), the location of the file can be set, and JPS, Jconsole will only read from the/tmp directory, but not from the set directory reading information, this is the second time I encountered the cause of the phenomenon

The parameter for setting the file location is -djava.io.tmpdir

Other:

The /tmp/hsperfdata_username/pid file is purged after the corresponding Java process exits . If the Java process exits abnormally (such as kill-9), then the PID file is retained until a Java command is executed or a command that loads the JVM program (such as JPS, Javac, jstat) clears all useless PID files

JPS Introduction and Resolution JPS unable to view a startup Java process issue "misappropriation"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.