Re: Restart TC with cron/sh
On Mon, Jul 7, 2008 at 8:43 AM, Piller Sébastien [EMAIL PROTECTED] wrote: Hello, I have my application in production for a month now. I've some problem of memory leak that force me to restart TC each few days. Or, you know, you could fix the actual problem - the memory leak. Go get yourself a profiler, and fix the problem :) This one is pretty good, and has a free demo: http://www.ej-technologies.com/products/jprofiler/overview.html - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
Piller Sébastien wrote: Hello, I have my application in production for a month now. I've some problem of memory leak that force me to restart TC each few days. I'm trying to automate this operation with a cron that runs a *.sh file. But I don't know how what to write in it. Actually, I've this: do you have shebang header in your script ? - something like this #!/bin/sh and do you have tomcat running under root ? -this is very not secure ... /usr/local/tomcat/bin/shutdown.sh killall -9 java /usr/local/tomcat/bin/startup.sh But when I run it using SSH, it makes a weird error: [EMAIL PROTECTED] bin]# /usr/local/tomcat/bin/restart.sh : No such file or directoryrt.sh: line 1:* /usr/local/tomcat/bin/shutdown.sh* are this script executable ? if not use chmod to set for example 755 permissions another thing about CRON , absolute paths to scripts must be used ... : no process killed Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/java/jre1.5.0_06 ... but shutdown.sh exists! Does anybody have an example of a script that restart Tomcat? I have one , I use it for my init script for tomcat ... if you are interesting in bash scripting , here is great manual http://www.tldp.org/LDP/abs/ or just google Advanced Bash-Scripting Guide restart.sh #!/bin/sh TOMCAT_USER=tomcat CATALINA_HOME=/opt/tomcat PATH=/bin:/sbin:/usr/bin:/usr/sbin startdaemon=$CATALINA_HOME/bin/startup.sh stopdaemon=$CATALINA_HOME/bin/shutdown.sh export CATALINA_HOME case $1 in start) sudo -u $TOMCAT_USER $startdaemon $CATALINA_HOME/logs/catalina.out 21 ;; stop) sudo -u $TOMCAT_USER $stopdaemon $CATALINA_HOME/logs/catalina.out 21 while [[ $i -lt 10 ]] do status=`pidof java 21/dev/null ; echo $?` if [[ $status == '0' ]] then echo -n . sleep 2 fi let i += 1 done status=`pidof java 21/dev/null ; echo $?` if [[ $status == '0' ]] then echo Killing ALL JAVA Processes /usr/bin/killall -9 java fi ;; restart) echo Stopping Tomcat $0 stop sleep 2 echo Starting Tomcat $0 start ;; *) echo Usage: $0 {start|stop|restart} exit 1 ;; esac exit 0 Thanks a lot! - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Restart TC with cron/sh
Hello, I have my application in production for a month now. I've some problem of memory leak that force me to restart TC each few days. I'm trying to automate this operation with a cron that runs a *.sh file. But I don't know how what to write in it. Actually, I've this: /usr/local/tomcat/bin/shutdown.sh killall -9 java /usr/local/tomcat/bin/startup.sh But when I run it using SSH, it makes a weird error: [EMAIL PROTECTED] bin]# /usr/local/tomcat/bin/restart.sh : No such file or directoryrt.sh: line 1:* /usr/local/tomcat/bin/shutdown.sh* : no process killed Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/java/jre1.5.0_06 ... but shutdown.sh exists! Does anybody have an example of a script that restart Tomcat? Thanks a lot! - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
Piller Sébastien ha scritto: Hello, I have my application in production for a month now. I've some problem of memory leak that force me to restart TC each few days. I'm trying to automate this operation with a cron that runs a *.sh file. But I don't know how what to write in it. Actually, I've this: /usr/local/tomcat/bin/shutdown.sh killall -9 java /usr/local/tomcat/bin/startup.sh But when I run it using SSH, it makes a weird error: [EMAIL PROTECTED] bin]# /usr/local/tomcat/bin/restart.sh : No such file or directoryrt.sh: line 1:* /usr/local/tomcat/bin/shutdown.sh* : no process killed Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/java/jre1.5.0_06 ... but shutdown.sh exists! Does anybody have an example of a script that restart Tomcat? Thanks a lot! If you are using debian (and other linux versions)maybe /etc/init.d/tomcat restart Edoardo -- Jabber: [EMAIL PROTECTED] tel: 075 9142766 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
Sorry, I've no tomcat in /etc/init.d/. Edoardo Panfili a écrit : If you are using debian (and other linux versions)maybe /etc/init.d/tomcat restart Edoardo - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
Piller Sébastien ha scritto: Sorry, I've no tomcat in /etc/init.d/. Are you using linux? if so, what distribution? How do you start Tomcat at startup time? edoardo Edoardo Panfili a écrit : If you are using debian (and other linux versions)maybe /etc/init.d/tomcat restart Edoardo - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jabber: [EMAIL PROTECTED] tel: 075 9142766 - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
Yes, we're running Linux. I'm not sure what's my distrib. I'm using our dedicated hosting, administrated via ssh. When I need to start tomcat, I just use the startup.sh script (the one in /bin/). Same to shutdown: use shutdown.sh. It's possible to restart TC with a .sh, isn't it? Edoardo Panfili a écrit : Piller Sébastien ha scritto: Sorry, I've no tomcat in /etc/init.d/. Are you using linux? if so, what distribution? How do you start Tomcat at startup time? edoardo Edoardo Panfili a écrit : If you are using debian (and other linux versions)maybe /etc/init.d/tomcat restart Edoardo - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
On Mon, July 7, 2008 4:11 pm, Piller Sébastien wrote: Yes, we're running Linux. I'm not sure what's my distrib. I'm using our dedicated hosting, administrated via ssh. When I need to start tomcat, I just use the startup.sh script (the one in /bin/). Same to shutdown: use shutdown.sh. Have you transferred the restart.sh from a windows box? Maybe you have dos/windows line breaks, which are CR+LF. Such a combination can kill a innocent looking shell script. It's possible to restart TC with a .sh, isn't it? Edoardo Panfili a écrit : Piller Sébastien ha scritto: Sorry, I've no tomcat in /etc/init.d/. Are you using linux? if so, what distribution? How do you start Tomcat at startup time? edoardo Edoardo Panfili a écrit : If you are using debian (and other linux versions)maybe /etc/init.d/tomcat restart Edoardo - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
On 07/07/2008, at 4:11 PM, Piller Sébastien wrote: Yes, we're running Linux. I'm not sure what's my distrib. I'm using our dedicated hosting, administrated via ssh. When I need to start tomcat, I just use the startup.sh script (the one in /bin/). Same to shutdown: use shutdown.sh. It's possible to restart TC with a .sh, isn't it? Dear Sébastien, You can use cron to stop and restart tomcat every day - A little bit of shell scripting may be required. The apache distribution of tomcat can be stopped and started by using cd $TOMCAT_HOME ./bin/shutdown.sh ./bin/startup.sh (some developers ASSUME that $TOMCAT_HOME is the working directory) As you are already having memory difficulties though, you may find that shutdown.sh does not work correctly - and that you may need to use kill -9. Either way however, should you be using this tomcat for a 'commercial purpose' running on a '*nix' machine, I can only strongly recommend that you find someone who can administer this machine. Best of luck. Andrew - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
Check to be sure the proper environment variables are set when the script runs. When I read the error message, I understand the error to be more like I can't find rt.sh from line 1 of /usr/local/tomcat/bin/shutdown.sh. You can test to confirm that suspicion by just dropping in an echo line at the beginning of shutdown.sh to confirm it is finding shutdown.sh and is executing it's contents. Also I'd be careful to put some sleep delay before the killall command as it can take a few seconds for tomcat to shutdown depending on how the webapps were designed. --David Piller Sébastien wrote: Hello, I have my application in production for a month now. I've some problem of memory leak that force me to restart TC each few days. I'm trying to automate this operation with a cron that runs a *.sh file. But I don't know how what to write in it. Actually, I've this: /usr/local/tomcat/bin/shutdown.sh killall -9 java /usr/local/tomcat/bin/startup.sh But when I run it using SSH, it makes a weird error: [EMAIL PROTECTED] bin]# /usr/local/tomcat/bin/restart.sh : No such file or directoryrt.sh: line 1:* /usr/local/tomcat/bin/shutdown.sh* : no process killed Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/java/jre1.5.0_06 ... but shutdown.sh exists! Does anybody have an example of a script that restart Tomcat? Thanks a lot! - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
Felix, Felix Schumacher a écrit : Have you transferred the restart.sh from a windows box? Maybe you have dos/windows line breaks, which are CR+LF. Such a combination can kill a innocent looking shell script. thank you, that was exactly what was wrong. I was using CR/LF-windows style EOL in my restart.sh. Now it works much more better :) Andrew Miehs a écrit : Either way however, should you be using this tomcat for a 'commercial purpose' running on a '*nix' machine, I can only strongly recommend that you find someone who can administer this machine. I'm the only one developper... So I've to do everything myself... Development, deployment, tuning, profiling, maintenance, customer calls, etc... Yes, I'm sometimes alone in the dark... - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Restart TC with cron/sh
The last answer of F. Schumacher was the right. I was messing with David Smith a écrit : Check to be sure the proper environment variables are set when the script runs. When I read the error message, I understand the error to be more like I can't find rt.sh from line 1 of /usr/local/tomcat/bin/shutdown.sh. You can test to confirm that suspicion by just dropping in an echo line at the beginning of shutdown.sh to confirm it is finding shutdown.sh and is executing it's contents. I put a ping 127.0.0.1 -c 10 between shutdown.sh and killall -9. Now it has a delay ~ 10s before the killall call. Also I'd be careful to put some sleep delay before the killall command as it can take a few seconds for tomcat to shutdown depending on how the webapps were designed. --David Thank you everybody for your advices :) - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]