RHEL Java application - specific name instead of generic java process

62 views Asked by At

I have a custom Java application running on my RHEL machine. I am running this Java application from a bash exec script with all the parameters and options appended. As a result, my Java application gets a generic name "java" in the system processes which is not useful for me as I would like to apply monitoring for this process (to know when it crashed or not) and the name is not unique, as well as I would potentially like to deploy another similar Java application, therefore I will not be able to distinguish them.

How to give my Java application a specific unique name?

Example from top below...

pid_no user      20   0  other_info java  
pid_no user      20   0  other_info java  
pid_no user      20   0  other_info java

Ideally I would like to have...

pid_no user      20   0  other_info my_app1  
pid_no user      20   0  other_info my_app2  
pid_no user      20   0  other_info my_app3 

Thank you in advance.

1

There are 1 answers

1
Michael Peacock On BEST ANSWER

It seems like you have maybe two relatively simple options -

  1. Create a soft link to java with your "desired" application name, and start your app with that

For Example:

ln -s /usr/bin/java /usr/bin/yourApp
/usr/bin/yourApp {options} YourApp.class
ps -ef |grep yourApp
  1. Pass a dummy parameter to your application at start up that identifies your app.

For example:

java {options} -DyourApp="yourApp" YourApp.class
ps -ef |grep yourApp

If your goal is to monitor the application, consider something like jvmtop or simply have the app write to a heartbeat log, and monitor that.