I have a simple service script tomcat7
in /etc/init.d/ to start and stop my app server (tomcat) under the tomcat user. On RHEL6.
#!/bin/bash
# description: Tomcat Start Stop
# processname: tomcat
# chkconfig: 234 20 80
CATALINA_HOME=/usr/local/www/tomcat-7.0.54
case $1 in
start)
/bin/su tomcat $CATALINA_HOME/bin/startup.sh
;;
stop)
/bin/su tomcat $CATALINA_HOME/bin/shutdown.sh 30
;;
esac
exit 0
Which works fine. Both startup.sh
and shutdown.sh
call a script called catalina.sh
. These are pre-made scripts that come with the app server.
I can use catalina.sh
directly like:
./catalina.sh stop 30 -force
Which lets me specify a wait time of 30 seconds and then does a kill -9 if the process hasn't ended. But I can't get the variables to work in the tomcat7
service script. If I change it to:
stop)
/bin/su tomcat $CATALINA_HOME/bin/catalina.sh stop 30 -force
I get an error:
[root@543917-web1 bin]# service tomcat7 stop
/bin/su: invalid option -- 'o'
Can I pass the three arguments without altering the catalina.sh script?
TIA