tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: Issue with sudo + init script
Date Wed, 01 Aug 2012 17:42:09 GMT
2012/8/1 Shaw, Ray V CTR (US) <>:
> I'm starting up Tomcat 7.0 on RHEL6 with the following init script:
> #!/bin/bash
> #
> # chkconfig: 235 80 20
> # description: Takes care of starting and stopping Tomcat.
> CATALINA_HOME="/opt/tomcat7"
> export JAVA_HOME="/usr/java/jdk6-64/"
> case "$1" in
>         'start')
>                 /bin/su tomcat -c "$CATALINA_HOME/bin/ -security"
>                 ;;
>         'stop')
>                 /bin/su tomcat -c $CATALINA_HOME/bin/
>                 ;;
>         *)
>                 echo "usage: $0 {start|stop}"
>                 ;;
> esac
> If I use sudo -s (or -i) to get a root shell, I can use this script to start and stop
> If I invoke this script directly via sudo, i.e. "sudo /sbin/service tomcat7 stop", stopping
Tomcat works.  Starting does not; Tomcat gives the usual output to the terminal, creates or
touches catalina.out (but writes nothing to it), and then instantly exits.  This is a problem,
because I need to allow the Web admin to start/stop Tomcat without giving them everything.
> Has anyone seen anything similar to this before?  /var/log/secure isn't showing anything
out of the ordinary (and obviously, the commands are being run).

Note that calling and  is just a wrapper for
calling with arguments "start" and "stop" respectively.
I'd recommend co call directly instead of those wrapper

Either java fails to start (and catalina.out is opened by shell as the
output stream of that process - it has nothing to do with Tomcat
itself),  or it terminates when its parent process terminates due to
HUP signal.

To exclude the former, try replace your command with " run
-security", so that Tomcat starts interactively in the same shell.

To exclude the later, maybe you should use "nohup" program to launch

Best regards,
Konstantin Kolinko

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message