主页

索引

模块索引

搜索页面

init.d目录

/etc/init.d/下文件书写格式:

 1#!/bin/sh
 2# chkconfig:   2345 90 10
 3# description:  Redis is a persistent key-value database
 4EXEC="/usr/local/redis-2.6.14/src/redis-server"
 5CLIEXEC="/usr/local/redis-2.6.14/src/redis-cli"
 6PIDFILE="/var/redis/redis.pid"
 7CONF="/usr/local/redis-2.6.14/redis.conf"
 8PORT="6379"
 9
10case "$1" in
11    start)
12        if [ -f $$PIDFILE ]
13        then
14                echo "$PIDFILE exists, process is already running or crashed."
15        else
16                echo "Starting Redis server..."
17                $EXEC $CONF
18        fi
19        ;;
20    stop)
21        if [ ! -f $PIDFILE ]
22        then
23                echo "$PIDFILE does not exist, process is not running."
24        else
25                PID=$(cat $PIDFILE)
26                echo "Stopping ..."
27                $CLIEXEC -p $PORT shutdown
28                while [ -x /proc/${PID} ]
29                do
30                    echo "Waiting for Redis to shutdown ..."
31                    sleep 1
32                done
33                echo "Redis stopped."
34        fi
35        ;;
36    restart)
37        $0 stop && $0 start
38        ;;
39    *)
40        echo "Usage: $0 {start|stop|restart}" >&2
41        exit 1
42        ;;
43esac

主页

索引

模块索引

搜索页面