0

I need to run a jar file in my linux VPS server for the whole day(continuously). But it stops in some time while running. For this I need to check if there is a way to check if the .jar file is running or not using a cronjob. if the file not running the cronjob can start the .jar file again. can anybody help me? If this question already answered plz send link.

Thanks in advance.

1
  • First check if the jar you are running already offers some kind of "watchdog" functionality. If yes, use this functionality unless is doesn't fit your needs. If it doesn't have such a functionality and you cannot change the source code, then you should look for the PID as mentioned in the answer from nablex Commented Sep 24, 2014 at 12:13

1 Answer 1

1

You can use this bit to get the pid:

JBOSS_PID=`ps -ef | grep org.jboss.modules.Main | grep -v grep | awk '{print $2}'` 

This is an example for a jboss server, you can see the main class in the grep. Switch this for your own class.

If the pid does not exist, start it. Run as frequently as you want.

Sign up to request clarification or add additional context in comments.

4 Comments

my module is buz_messenger. How can i use for this. Sorry I'm not expert in java programing
How do you start it? With a bash file? If so, you can find the name of the main class in the bash file.
Im using java -cp buz_messenger.jar com.svs.trade.server.buz_messenger
Then the class is com.svs.trade.server.buz_messenger (odd name for a class but hey...). Replace the org.jboss.modules.Main with that class

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.