tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ayhan Peker <ay...@image-data.com>
Subject crontab problems
Date Tue, 25 Feb 2003 09:29:35 GMT
Hi everybody ,
I have a problem..I am trying to write an application , which will run from 
cronatb on linux...
My application runs without a problem when i try it from the command 
line..BUT NOT FROM CRONTAB...
The challenge is: if jvm crashes i want to restart tomcat....
my code is :
String[] command ={ "/bin/sh", "-c", "ps -ex | grep Djava.endorsed.dirs"};
int processcount=0;
Runtime r = Runtime.getRuntime();
Process p = r.exec(command);
InputStreamReader isr=new InputStreamReader(p.getInputStream());
BufferedReader br=new BufferedReader(isr);
String line=null;
while((line = br.readLine()) != null){
System.out.println(line);
processcount++;
}
if i decide to restart the server
i execute :
String[] command_ ={"sh","-c","/root/adminscripts/restart_tomcat"};
Process p2 = Runtime.getRuntime().exec(command_);
but the last two lines returns
/////////////////////////
The JAVA_HOME environment variable is not defined
message..
/////////////////////////
my retstart_tomcat scrip is
#!/bin/sh
cd /usr/local/tomcat/bin
./startup.sh
i will really appreciate if somebody helps..
basicly...
-run the crontab every min..
-invoke a java programme..
-programme counts the java-threads..
-decides if tomcat needs restarting..
-restarts tomcat..
my crontab script is:
* * * * * su root && cd /usr/local/tomcat/bin && /usr/local/java/bin/java

-cp /usr/local/tomcat/bin/ TomcatwatcherThread >> 
/var/log/tomcat/restart.log 2>&1
please help..
Thanks








---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message