shamuk80
4th April 2008, 10:51
Hi All
I have installed tomcat on RHEL4/5. It doesnt create start/stop scripts in /etc/rc.d/init.d/ --> /etc/init.d/.
Now i am stoping and starting tomcat by
#/opt/tomcat/bin/startup.sh
#/opt/tomcat/bin/shutdown.sh
but i want to configure this in a script in init.d/ directory.
I tired my self by writing a script after seeing the others in /etc/rc.d/init.d/
#!/bin/bash
#
# description: Jakarta Tomcat Java Servlets and JSP server
# processname: tomcat
start_tomcat=/opt/tomcat/bin/startup.sh
stop_tomcat=/opt/tomcat/bin/shutdown.sh
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
start() {
echo -n "Starting tomcat: "
su -c ${start_tomcat} - tomcat
echo "done."
}
stop() {
echo -n "Shutting down tomcat: "
# Add stop flag file
touch $CATALINA_HOME/temp/.manualStop
su -c ${stop_tomcat} - tomcat
echo "done."
}
# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
but i am getting error if i run this script.
[root@localhost /]/etc/init.d/tomcat stop
-bash: /etc/init.d/tomcat: /bin/sh^M: bad interpreter: No such file or directory.
/etc/init.d/tomcat start/stop/restart.
Can any body help me to see whats wrong here?
Thanks.
I have installed tomcat on RHEL4/5. It doesnt create start/stop scripts in /etc/rc.d/init.d/ --> /etc/init.d/.
Now i am stoping and starting tomcat by
#/opt/tomcat/bin/startup.sh
#/opt/tomcat/bin/shutdown.sh
but i want to configure this in a script in init.d/ directory.
I tired my self by writing a script after seeing the others in /etc/rc.d/init.d/
#!/bin/bash
#
# description: Jakarta Tomcat Java Servlets and JSP server
# processname: tomcat
start_tomcat=/opt/tomcat/bin/startup.sh
stop_tomcat=/opt/tomcat/bin/shutdown.sh
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
start() {
echo -n "Starting tomcat: "
su -c ${start_tomcat} - tomcat
echo "done."
}
stop() {
echo -n "Shutting down tomcat: "
# Add stop flag file
touch $CATALINA_HOME/temp/.manualStop
su -c ${stop_tomcat} - tomcat
echo "done."
}
# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
but i am getting error if i run this script.
[root@localhost /]/etc/init.d/tomcat stop
-bash: /etc/init.d/tomcat: /bin/sh^M: bad interpreter: No such file or directory.
/etc/init.d/tomcat start/stop/restart.
Can any body help me to see whats wrong here?
Thanks.