Here is a shell script to manage the Redis process (start, stop, restart), which is a script for reference.
#!/bin/sh
#
# Redis-this script starts and stops the Redis-server daemon
#
# Chkconfig:-85 15
# Description:redis is a persistent key-value database
# Processname:redis-server
# config:/usr/local/webserver/redis-2.4.4/bin/redis-server
# config:/usr/local/webserver/redis-2.4.4/etc/redis.conf
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
["$NETWORKING" = "no"] && exit 0
Redis= "/usr/local/webserver/redis-2.4.4/bin/redis-server"
prog=$ (basename $redis)
Redis_conf_file= "/usr/local/webserver/redis-2.4.4/etc/redis.conf"
[-f/etc/sysconfig/redis] &&. /etc/sysconfig/redis
Lockfile=/var/lock/subsys/redis
Start () {
[-X $redis] | | Exit 5
[-F $REDIS _conf_file] | | Exit 6
Echo-n $ "Starting $prog:"
Daemon $redis $REDIS _conf_file
Retval=$?
Echo
[$retval-eq 0] && Touch $lockfile
Return $retval
}
Stop () {
Echo-n $ "Stopping $prog:"
Killproc $prog-quit
Retval=$?
Echo
[$retval-eq 0] && rm-f $lockfile
Return $retval
}
Restart () {
Stop
Start
}
Reload () {
Echo-n $ "Reloading $prog:"
Killproc $redis-hup
Retval=$?
Echo
}
Force_reload () {
Restart
}
Rh_status () {
Status $prog
}
Rh_status_q () {
Rh_status >/dev/null 2>&1
}
Case "$" in
Start
Rh_status_q && Exit 0
$
;;
Stop
Rh_status_q | | Exit 0
$
;;
Restart|configtest)
$
;;
Reload
Rh_status_q | | Exit 7
$
;;
Force-reload)
Force_reload
;;
Status
Rh_status
;;
Condrestart|try-restart)
Rh_status_q | | Exit 0
;;
*)
echo $ "Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
Exit 2
Esac
chmod 755/etc/rc.d/init.d/redis
[[Email protected]_web_s1 init.d]# service Redis start
Starting redis-server: [OK]
[[Email protected]_web_s1 init.d]# Service Redis stop
stopping redis-server: [OK]
Add to boot Boot
Chkconfig--add Redis
Chkconfig--level 3 Redis on
[Reprint] Shell scripts to manage Redis processes