Code: Select all
#!/bin/bash
# chkconfig: 345 90 10
# processname: tomcat_all
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/tomcat_all
SCRIPT_LOC="/app/Tomcat_Maintain_Script"
case "$1" in
'start')
if [ -f $LOCKFILE ]; then
echo $0 already running.
exit 1
fi
echo -n $"Starting tomcat_all....."
nohup sh $SCRIPT_LOC/ROOR_sync.sh > /dev/null 2>&1 &
nohup sh $SCRIPT_LOC/swap.sh > /dev/null 2>&1 &
nohup sh $SCRIPT_LOC/upload_sync.sh > /dev/null 2>&1 &
nohup sh $SCRIPT_LOC/Tomcat_Auto_Maintain.sh > /dev/null 2>&1 &
touch $LOCKFILE
;;
'stop')
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
rm -rf $LOCKFILE
exit 1
fi
echo -n $"Stopping tomcat_all......"
ps -ef | grep "ROOT_sync.sh" | awk '{print $2}' | xargs kill > /dev/null 2>&1 &
ps -ef | grep "swap.sh" | awk '{print $2}' | xargs kill > /dev/null 2>&1 &
ps -ef | grep "upload_sync.sh" | awk '{print $2}' | xargs kill > /dev/null 2>&1 &
ps -ef | grep "Tomcat_Auto_Maintain.sh" | awk '{print $2}' | xargs kill > /dev/null 2>&1 &
rm -rf $LOCKFILE
;;
'restart')
$0 stop
$0 start
echo -n $"Restarting tomcat_all......"
;;
'status')
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "Usage: $0 [start|stop|status]"
exit 1
esac
exit 0