第一个
#!/bin/sh
# chkconfig: 2345 10 90
# description: Start and Stop redis
REDISPORT=6379
EXEC=/usr/local/mio/redis/bin/redis-server
CLIEXEC=/usr/local/mio/redis/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/mio/redis/bin/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
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Please use start or stop or restart as first argument"
;;
esac
第二个 时间太长忘记是做什么的 先移植过来
#!/bin/sh
# chkconfig: 2345 10 90
# description: Start and Stop redis_slave
start() {
/usr/local/redis_slave/bin/redis-server /usr/local/redis_slave/bin
/redis.conf
}
stop() {
numproc=`ps -ef | grep redis_slave | grep -v grep|awk '{pri
nt $2}'`
if [ "$numproc" = "" ]; then
echo "redis_slave is stopped..."
else
echo "redis_slave is $numproc"
kill -9 $numproc
echo "redis_slave is stopped..."
fi
}
status() {
numproc=`ps -ef|grep redis_slave|grep -v grep|wc -l`
if [[ "$numproc" == 0 ]]; then
echo "redis_slave is stop... $numproc"
else
echo "redis_slave is start... $numproc"
fi
}
restart(){
numproc=`ps -ef | grep redis_slave | grep -v "grep" | aw
k '{print $2}'`
if [ "$numproc" = "" ]
then
echo "redis_slave is stopped..."
else
echo "redis_slave is $numproc"
kill -9 $numproc
echo "redis_slave is stopped..."
fi
echo "redis_slave is starting..."
/usr/local/redis_slave/bin/redis-server /usr/local/redis_slave/bin
/redis.conf
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0
第三个 忘记干嘛的
#!/bin/sh
# chkconfig: 2345 10 90
# description: Start and Stop redis
start() {
/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
}
stop() {
numproc=`ps -ef | grep redis | grep -v grep|awk '{pri
nt $2}'`
if [ "$numproc" = "" ]; then
echo "redis is stopped..."
else
echo "redis is $numproc"
kill -9 $numproc
echo "redis is stopped..."
fi
}
status() {
numproc=`ps -ef|grep redis|grep -v grep|wc -l`
if [[ "$numproc" == 0 ]]; then
echo "redis is stop... $numproc"
else
echo "redis is start... $numproc"
fi
}
restart(){
numproc=`ps -ef | grep redis | grep -v "grep" | aw
k '{print $2}'`
if [ "$numproc" = "" ]
then
echo "redis is stopped..."
else
echo "redis is $numproc"
kill -9 $numproc
echo "redis is stopped..."
fi
echo "redis is starting..."
/usr/local/redis/bin/redis-server /usr/local/redis/
bin/redis.conf
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0