zoukankan      html  css  js  c++  java
  • centos redis自启动

    #!/bin/sh
    # chkconfig:   2345 90 10
    # description:  Redis is a persistent key-value database
    # Simple Redis init.d script conceived to work on Linux systems
    # as it does use of the /proc filesystem.
    
    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    CLIEXEC=/usr/local/bin/redis-cli
    
    PIDFILE=/var/run/redis_${REDISPORT}.pid
    #CONF="/etc/redis/${REDISPORT}.conf"
    CONF="/home/bag/redis-3.2.1/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
            ;;
        stop)
            if [ ! -f $PIDFILE ]
            then
                    echo "$PIDFILE does not exist, process is not running"
            else
                    PID=$(cat $PIDFILE)
                    echo "Stopping ..."
                    $CLIEXEC -p $REDISPORT shutdown
                    while [ -x /proc/${PID} ]
                    do
                        echo "Waiting for Redis to shutdown ..."
                        sleep 1
                    done
                    echo "Redis stopped"
            fi
            ;;
        *)
            echo "Please use start or stop as first argument"
            ;;
    esac
    

      

    其实这个文件,在redis安装目录的utils目录也有,不要在前面加上

    # chkconfig:   2345 90 10
    # description:  Redis is a persistent key-value database
    

      

    即可。

    设置开机启动

    复制该文件到/etc/init.d/redis

    然后设置开机启动命令

    sudo chkconfig redis on 
    

      

  • 相关阅读:
    java抽象类和接口
    java的三大特征:封装,继承和多态
    java的数组
    django 4.get接口开发
    django 3.post接口开发
    C# 程序启动最小化至任务栏及闪烁
    续Html5
    使用intellij idea搭建MAVEN+SSM(Spring+SpringMVC+MyBatis)框架
    Spring MVC拦截器
    Html5高级
  • 原文地址:https://www.cnblogs.com/zenghansen/p/7866420.html
Copyright © 2011-2022 走看看