jps usage and FAQ Introduction

1, jps role

jps similar linux ps command, except that ps is used to display the process, but jps show only java process, accurate to say that the current user has started the part java process information, process information, including number and a short process command.

 

2, a java process has already started, with jps but can not display the process ID process

This problem has been encountered twice, so here under the summary.

phenomenon:

Using ps -ef | grep java java could see the start of the process, but with a view jps id of the process does not exist . After a little later explained able to know in this case, JConsole, jvisualvm may not be able to monitor the process, the tool also comes with other java may not be available

 

analysis:

After java program starts, the default (please note that the default) will under / tmp / hsperfdata_userName directory id of the process for the file name new file, and store information jvm to run in the file , which userName for the current user name, / tmp / hsperfdata_userName directory contains all the java process information that the user has already started. For windows machine / tmp directory with Windows temporary files instead.

 

The data source jps, jconsole, jvisualvm and other tools is this file ( / tmp / hsperfdata_userName / pid) . So there will be jps can not view the process ID, jconsole can not monitor issues such as when the file does not exist or can not be read

 

the reason:

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

If the user does not have permission to write the / tmp directory or the disk is full, you can not create / tmp / hsperfdata_userName / pid file. Or the file has been generated, but the user does not have permission to read

 

(2), temporary files lost, deleted or cleaned regularly

For the linux machine, usually there is a scheduled task to clean up the temporary folder, resulting in the / tmp directory is emptied. This is my first reason for this phenomenon is encountered. Commonly used may regularly delete temporary directory tool for crontab, redhat's tmpwatch, ubuntu is tmpreaper etc.

This phenomenon may be due to this, with jconsole monitoring process, the discovery process still exists after a certain period of time, but there is no monitoring of the information.

 

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

Above we said in the introduction by default in / tmp / hsperfdata_userName directory save process information, but because of the above reasons 1, 2, may result in the file can not be generated or lost, it provides parameters java launcher ( -Djava.io .tmpdir) , you can set the location of the file, and jps, jconsole will only read from the / tmp directory, the directory can not be set after reading the information from, which is why the second time I encountered this phenomenon

 

About setting the parameter file location is -Djava.io.tmpdir

 

other:

/ tmp / hsperfdata_userName / pid file will clear after the corresponding java process to exit . If the java process to exit abnormally (eg kill -9), then pid file will be retained until a java command or commands to load the jvm program (such as jps, javac, jstat), all will be useless pid file clear out

 

More about jps description, see the oracle introduction  http://download.oracle.com/javase/1.5.0/docs/tooldocs/share/jps.html

  Quoted from the article: http: //trinea.iteye.com/blog/1196400

Guess you like

Origin www.cnblogs.com/jpfss/p/11313248.html