1、redis启动脚本

#!/bin/bash

#

#chkconfig: - 80 10

#description: start redis

#processname:redis


#=====================================================

#IPADDR=`/sbin/ifconfig eth1 |awk -F ':' '/inet addr/{print $2}' | sed 's/[a-zA-Z]//g'`

BINFILE="/usr/local/bin/redis-server"

CONFFILE="/etc/redis.conf"


start(){

        stop

        sleep 1

        echo -n $"Starting redis.."

        $BINFILE $CONFFILE

        echo -e 

}


stop(){

        echo -n $"Shutting down redis..."

        /bin/kill -9 `/sbin/pidof redis-server`

        echo -e

}


restart(){

        stop

        sleep 1

        start

}


case "$1" in

start)

        start

        ;;

stop)

        stop

        ;;

restart)

        restart

        ;;

*)

        echo "Usage: $0 {start|stop|restart|condrestart|status}"

esac


2、把脚本放在/etc/init.d/目录下


3、设置开机启动,命令:chkconfig redis on


4、测试命令:

    service redis start

     ps -ef|grep redis

    service redis stop