Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a script like below to monitor our server. During this code our server getting restarted. Can anyone please explain the meaning of below script?

if [ -f $HOME/catalinamonitor ]; then
  echo JVM failed;
  export JAVA_HOME=/usr/java/jdk1.6.0
  sleep 30
  /usr/bin/killall -9 java 2>/dev/null
  rm -f $HOME/catalinamonitor
  exit 1
share|improve this question
up vote 2 down vote accepted

If the file $HOME/catalinamonitor exists, write JVM failed to the screen. Put the value /usr/java/jdk1.6.0 in JAVA_HOME and make it an environment variable.

Run the script in $HOME/jakarta-tomcat/bin/, wait 30 seconds and kill all processes that are java. All output will be redirected to /dev/null (not shown on screen).

Run the following script $HOME/jakarta-tomcat/bin/ and delete the file rm -f $HOME/catalinamonitor. Terminate the script with an error (1).

So basically, If a file exists, kill all tomcat and java, then restart it and delete the file.

share|improve this answer
Thanks !!! Any idea catalinamonitor would create automcaticaly? If so at which case – Selvakumar P Feb 20 '12 at 12:16
Probably it's a file created by another script after doing a check (probably some sort of check on the tomcat-server). Maybe something in the same script? – Bart De Vos Feb 20 '12 at 13:36
the script file has like this touch $HOME/catalinamonitor, this executes every 10 mins. Apart from this we dont have anything related to catalinamonitor – Selvakumar P Feb 20 '12 at 13:42
And when does it do the touch $HOME/catalinamonitor? That is when the script says it's necessary to restart the tomcat-server. – Bart De Vos Feb 20 '12 at 13:46
The first part of the script is what I have mentioned in the question, Second part has touch command. Both are in same script file which will be excuted every 10 mins as set in cron job – Selvakumar P Feb 21 '12 at 4:26

A way better solution is to use YAJSW or similar as a watchdog. I cringed at the killall...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.