0

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.

Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135
croussou
  • 77
  • 1
  • 6
  • You can try something like `exec -a goodname java ...`, copied from - http://stackoverflow.com/questions/882826/how-to-change-the-name-of-a-java-application-process – TheCodingFrog Jun 10 '15 at 13:09
  • You can try 'top -c' for the full command – Marinos An Jun 10 '15 at 13:12
  • I have tried that one and it works but that does not rename the process, rather appends another name in the beginning, before all the other parameters :| I have read that it might be quite difficult to do so, I am not sure yet... – croussou Jun 10 '15 at 13:28
  • I see that Launch4j might help, is anyone familiar with it and can share some info? – croussou Jun 10 '15 at 13:43
  • Maybe this post will help you http://serverfault.com/questions/23236/giving-a-process-a-specific-name-in-gnu-linux . – Nicolai Jun 10 '15 at 13:46

1 Answers1

0

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.

Michael Peacock
  • 2,011
  • 1
  • 11
  • 14
  • Thank you for your reply. I have managed to get this sorted with the use of monit...basically I have first registered the applications as services, using skeleton as a template and then placed those scripts in /etc/init.d/...it seems monit doesn't care if there is no process name as such it's just an alias to show the different processes in the GUI I suppose. – croussou Jun 11 '15 at 05:35