成都创新互联网站制作重庆分公司

Redis启动脚本,开机自动启动

# chkconfig:   2345 90 10

成都创新互联公司主营呼兰网站建设的网络公司,主营网站建设方案,成都app开发,呼兰h5重庆小程序开发搭建,呼兰网站营销推广欢迎呼兰等地区企业咨询

# description:  redis is a persistent key-value database

 

PATH=$PATH:/usr/local/redis/bin:/sbin:/usr/bin:/bin

 

REDISPORT=6379

EXEC=/usr/local/redis/bin/redis-server

REDIS_CLI=/usr/local/redis/bin/redis-cli

PASS=chbin123 

PIDFILE=/var/run/redis_6379.pid

CONF="/usr/local/redis/etc/redis.conf"

 

case "$1" in

    start)

        if [ -f $PIDFILE ]

        then

                echo "$PIDFILE exists, process is already running or crashed"

        else

                echo "Starting Redis server..."

                $EXEC $CONF

        fi

        if [ "$?"="0" ] 

        then

              echo "Redis is running..."

        fi

        ;;

    stop)

        if [ ! -f $PIDFILE ]

        then

                echo "$PIDFILE does not exist, process is not running"

        else

                PID=$(cat $PIDFILE)

                echo "Stopping ..."

                $REDIS_CLI -a $PASS -p $REDISPORT SHUTDOWN

                while [ -x ${PIDFILE} ]

               do

                    echo "Waiting for Redis to shutdown ..."

                    sleep 1

                done

                echo "Redis stopped"

        fi

        ;;

   restart|force-reload)

        ${0} stop

        ${0} start

        ;;

  *)

    echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2

        exit 1

esac

-----------------------------

添加redis服务开机启动:

chmod +x /etc/init.d/redis

启动redis服务:

service redis start

检查服务是否启动

ps -ef | grep redis

netstat -anptu | grep 6379


网页标题:Redis启动脚本,开机自动启动
分享网址:http://cxhlcq.com/article/igepso.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部