Link to home
Start Free TrialLog in
Avatar of pal2k
pal2kFlag for United States of America

asked on

Unix shell script start tomcat server(JVM) and exit

simple Shell script to start a tom cat server (JVM) and if for some reason if server does not start within 3 mins exit and  also find any hung jvm tomcat start commands fired and force kill it.
Avatar of Kerem ERSOY
Kerem ERSOY

I guess

killall -9 <your_script_name> 

Open in new window


would kill all previous instances of the script.

To restart your code should be something like that:

java <parameters> <your_program_name> &

Open in new window


Please mind
the trailing ampersand which will put your program on background.
Avatar of pal2k

ASKER

I have a shell script to start a tom cat server. Right now it waits until it trying to start the server and does not exit. Wondering what unix cmd to add to wait for 3 mins if start cmd is hung ?
Avatar of pal2k

ASKER

I mean wait for 3 mins and if does not start exit shell script
Avatar of pal2k

ASKER

for now I'm planning to take care killing part manually
You use the sleep command to wait for some time, like sleep 180 to wait 3 minutes (this is quite a long time for tomcat to start actually). After waiting I would suggest you use a command line browser to see if your tomcat is working (lynx). If you don't get a reply then use the ps command with some filtering to find and kill leftover processes. How exactly are you starting your tomcat?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.