tomcat nginx 启动脚本示例

init.d 里

1 tomcat

#!/bin/bash
### BEGIN INIT INFO
# Provides: tomcat6
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: $named
# Should-Stop: $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Tomcat.
# Description: Start the Tomcat servlet engine.
### END INIT INFO


TOMCAT_USER=www
TOMCAT_GROUP=www
TOMCAT_HOME=/alidata/server/tomcat7
TOMCAT_BIN=$TOMCAT_HOME/bin
TOMCAT_TEMP=$TOMCAT_HOME/temp
TOMCAT_LOCK=/var/run/tomcat.lock
JAVA_HOME=/alidata/server/java
TOMCAT_UMASK=002


if [ `id -u` -ne 0 ]; then
echo "You need root or sudo privileges to run this script"
exit 1
fi


start_sams() {
if [ -f $TOMCAT_LOCK ];then
echo ' * SAMS has already been started or has problems'
echo ' * Please contact Tomas'
exit 1
fi
start-stop-daemon --start -u "$TOMCAT_USER" -g "$TOMCAT_GROUP" \
-c "$TOMCAT_USER" -d "$TOMCAT_TEMP" \
-k "$TOMCAT_UMASK" -x "$TOMCAT_BIN/startup.sh" > /dev/null && \
echo " * SAMS starts successfully" && touch $TOMCAT_LOCK

}

stop_sams() {
if [ ! -f $TOMCAT_LOCK ];then
echo ' * SAMS has already been stopped or has problems'
echo ' * Please contact Tomas'
exit 1
fi
start-stop-daemon --stop -u "$TOMCAT_USER" -g "$TOMCAT_GROUP" \
-c "$TOMCAT_USER" -d "$TOMCAT_TEMP" \
-k "$TOMCAT_UMASK" "$TOMCAT_BIN/shutdown.sh" && \
echo " * SAMS stops successfully" && rm -f $TOMCAT_LOCK
}


case "$1" in
start)
start_sams
;;
stop)
stop_sams
;;
restart)
stop_sams
sleep 1
start_sams
;;
*)
echo ' * Usage: /etc/init.d/tomcat_sams {start|stop|restart}'
exit 1
;;
esac

2 nginx

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# this script create it by ruijie. at 2014.02.26
# if you find any errors on this scripts,please contact ruijie.
# and send mail to ruijie at gmail dot com.
#            ruijie.qiao@gmail.com

nginxd=/alidata/server/nginx/sbin/nginx
nginx_config=/alidata/server/nginx/conf/nginx.conf
nginx_pid=/alidata/server/nginx/logs/nginx.pid

RETVAL=0
prog="nginx"

[ -x $nginxd ] || exit 0

# Start nginx daemons functions.
start() {
    
    if [ -e $nginx_pid ] && netstat -tunpl | grep nginx &> /dev/null;then
        echo "nginx already running...."
        exit 1
    fi
        
    echo -n $"Starting $prog!"
    $nginxd -c ${nginx_config}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/nginx
    return $RETVAL
}


# Stop nginx daemons functions.
stop() {
    echo -n $"Stopping $prog!"
    $nginxd -s stop
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/nginx
}


# reload nginx service functions.
reload() {

    echo -n $"Reloading $prog!"
    #kill -HUP `cat ${nginx_pid}`
    $nginxd -s reload
    RETVAL=$?
    echo

}

# See how we were called.
case "$1" in
start)
        start
        ;;

stop)
        stop
        ;;

reload)
        reload
        ;;

restart)
        stop
        start
        ;;

*)
        echo $"Usage: $prog {start|stop|restart|reload|help}"
        exit 1
esac

exit $RETVAL

 

 

转载于:https://my.oschina.net/u/1015065/blog/749917

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值