The usual thing is to save it to init.d and then link to the rc[235].d
of
your choice.
If you've got redhat you can use the chkconfig program on it.
Note though that you'll need to add a user 'tomcat' and make
sure that at least the conf and logs directories are
availible for writing by that user.
You might want to make a 'web' group...
i've also added
------- 8< snip --------
DATE=`date +%Y-%m-%d-%H-%M-%S`
mkdir $TOMCAT/logs/$DATE
mv $TOMCAT/logs/*.log $TOMCAT/logs/$DATE
-------8<---- snip --------
into my shutdown.sh script. This then saves all of your logs when you
do a shutdown - which can be useful !
David
"Roberto B." wrote:
>
> Do I have to insert this script in my rc2.d dir. and link it in init.d ?
>
> R.
>
> ----- Original Message -----
> From: "David Cassidy" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, August 17, 2001 5:06 PM
> Subject: Re: Why and How Tomcat before Apache?
>
> > Ah what the hell try this ...
> > ( works for me !)
> >
> >
> > Watch out for the line wraps !
> >
> >
> > ------------- 8< -- snip
> > #!/bin/sh
> >
> > # Init file for Jakarta Tomcat
> > #
> > # chkconfig: 345 98 00
> > # description: Jakarta tomcat daemon
> > #
> > # processname:
> > # config: /usr/local/tomcat/conf/server.xml
> >
> > RETVAL=0
> >
> > TOMCAT_HOME=/usr/local/tomcat
> > export TOMCAT_HOME
> >
> > case "$1" in
> > start)
> > F=`$0 status`
> > if [ "$?" = "255" ] ; then
> > echo -n "Starting Tomcat : "
> > su - tomcat -c "cd $TOMCAT_HOME/bin;
> > $TOMCAT_HOME/bin/startup.sh > $TOMCAT_HOME/logs/tomcat_stdout.log 2>
> > $TOMCAT_HOME/logs/tomcat_stderr.log"
> > echo " [ OK ] "
> > else
> > echo "Tomcat is already running"
> > fi
> > echo
> > ;;
> > stop)
> > F=`$0 status`
> > if [ "$?" = "255" ] ; then
> > echo "Tomcat isn't running"
> > else
> > echo -n "Shutting down Tomcat : "
> > su - tomcat -c "cd $TOMCAT_HOME/bin ;
> > $TOMCAT_HOME/bin/shutdown.sh >
> $TOMCAT_HOME/logs/tomcat_down_stdout.log
> > 2> $TOMCAT_HOME/logs/tomcat_down_stderr.log"
> > echo " [ OK ] "
> > fi
> > echo
> > ;;
> > restart)
> > $0 stop
> > sleep 2
> > $0 start
> > RETVAL=$?
> > ;;
> > status)
> > S=`ps auxww | grep org.apache.tomcat.startup.Tomca[t] | wc -l`
> > E=`expr $S`
> > if [ "$E" = "0" ] ;then
> > echo "Tomcat is stopped"
> > RETVAL=-1
> > else
> > PIDS=`ps auxww | grep
> org.apache.tomcat.startup.Tomca[t]
> > | awk '{FS=" "}{print $2}'`
> > P=`echo $PIDS`
> > echo "Tomcat ( $P ) is running"
> > RETVAL=0
> > fi
> > ;;
> > *)
> > echo "Usage: tomcat {start|stop|restart|status}"
> > exit 1
> > esac
> >
> > exit $RETVAL
> >
> > ------------- 8< -- snip
> >
> >
> > David Cassidy wrote:
> > >
> > > unless you want to run your tomcat as root ( Very unwise )
> > > makesure that you use a 'su' command in your
> > > call to tomcat's start script...
> > >
> > > David
> > >
> > > Rui Miguel Seabra wrote:
> > > >
> > > > Just hack apachectl script to launch tomcat just before apache,
> and to
> > > > shut it down right aftwards.
> > > >
> > > > On 17 Aug 2001 16:43:41 +0200, Roberto B. wrote:
> > > > > Ok ! but.. do you know the way to make this in automatic ( with
> > > > scripts at
> > > > > system start ) ??
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Barnabas Yohannes" <[EMAIL PROTECTED]>
> > > > > To: <[EMAIL PROTECTED]>
> > > > > Sent: Friday, August 17, 2001 3:39 PM
> > > > > Subject: Re: Why and How Tomcat before Apache?
> > > > >
> > > > >
> > > > > > I cannot answer your "why" question, because, I am not one of
> the
> > > > > developers
> > > > > > of apache or tomcat. But here is the answer to your "how"
> > > question:
> > > > > >
> > > > > > *To stop and start your tomcat:
> > > > > >
> > > > > > cd /usr/local/tomcat
> > > > > >
> > > > > > bin/shutdown.sh
> > > > > >
> > > > > > bin/startup.sh
> > > > > >
> > > > > > *Exit from tomcat and go to your apache server:
> > > > > >
> > > > > > su
> > > > > >
> > > > > > /usr/local/apache/bin/apachectl restart
> > > > > >
> > > > > > exit
> > > > > >
> > > > > > * Another way of stopping and starting apache:
> > > > > >
> > > > > > bin/apachectl stop
> > > > > > bin/apachectl start
> > > > > >
> > > > > >
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "Roberto B." <[EMAIL PROTECTED]>
> > > > > > To: <[EMAIL PROTECTED]>
> > > > > > Sent: Friday, August 17, 2001 4:50 AM
> > > > > > Subject: Why and How Tomcat before Apache?
> > > > > >
> > > > > >
> > > > > > > I have a Linux/Debian system.
> > > > > > > I want to use Apache as web-server and Tomcat only for JSP
> file.
> > > > > > >
> > > > > > > Is it true that it is necessary to make start Tomcat before
> > > > Apache?
> > > > > Why?..
> > > > > > > and if it is true.. how??
> > > > > > >
> > > > > > > Thanks!
> > > > > > > Roberto.
> > > > > > >
> > > > > > >
> > > > >
> > > > --
> > > > + No matter how much you do, you never do enough -- unknown
> > > > + Whatever you do will be insignificant,
> > > > | but it is very important that you do it -- Ghandi
> > > > + So let's do it...?