Arquivo da categoria: Shell Script

Script Shell de serviço no linux

O script vai ficar na pasta “/etc/init.d” e depois basta dar um:

sudo nano tomcat7

Depois que abrir o editor basta colar isso:

#!/bin/sh
#
# description: Tomcat Server basic start/shutdown script
# processname: tomcat

# Source function library.
if [ -f /etc/rc.d/init.d/functions ];
then
    . /etc/rc.d/init.d/functions
fi


JAVA_HOME=/usr/java/latest
export JAVA_HOME

TOMCAT_HOME=/opt/tomcat/bin
START_TOMCAT=/opt/tomcat/bin/startup.sh
STOP_TOMCAT=/opt/tomcat/bin/shutdown.sh
VERSION_TOMCAT=/opt/tomcat/bin/version.sh

 start() {
     echo -n "Starting tomcat: "
     cd $TOMCAT_HOME
     ${START_TOMCAT}
     echo "done."
 }

 stop() {
     echo -n "Shutting down tomcat: "
     cd $TOMCAT_HOME
     ${STOP_TOMCAT}
     echo "done."
 }

 case "$1" in
          start)
             start
           ;;

          stop)
             stop
           ;;

         restart)
           stop
           sleep 10
           start
           ;;
         *)
           echo "Usage: $0 {start|stop|restart}"
 esac
 exit 0

Site de referência: http://askubuntu.com/questions/223944/how-to-automatically-restart-tomcat7-on-system-reboots/224402

Share and Enjoy !

0Shares
0 0