189 8069 5689

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://cdxtjz.cn/article/igepso.html

其他资讯