Get the App
SLTechnology News&Howtos  ›  Database  › 

How to write the redis startup management script

Shulou Source: shulou.com Published: 2022-05-31 14:14:26 10月05日 Update

This article mainly introduces how to write the redis startup management script, the article introduces in great detail, has a certain reference value, interested friends must read it!

I am redis-3.0.5 installed by source code.

Installation path / usr/local/redis

Edit the create script file:

Vim / etc/init.d/redis

#! / bin/sh## chkconfig: 2345 85 15 # description: this script can manager the redis-server daemon# Redis is a persistent key-value database# exec: / usr/local/redis/bin/redis-server# config: / usr/local/redis/conf/redis.conf # pidfile: / usr/local/redis/logs/redis.pid # datafile: / usr/local/redis/data/redis.rdb redis= "/ Usr/local/redis/bin/redis-server "REDIS_CONF_FILE=" / usr/local/redis/conf/redis.conf "prog=$ (basename $redis) lockfile=/var/lock/subsys/redis# Source function library.. / etc/rc.d/init.d/functions # Source networking configuration.. / etc/sysconfig/network # Check that networking is up. ["$NETWORKING" = "no"] & & exit 0 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} rh_status () {status $prog} rh_status_q () {rh_status > / dev/null 2 > & 1} case "$1" in start) rh_status_q & & exit 0 $1;; stop) rh_status_q | | exit 0 $1;; restart) $1 Reload) rh_status_q | | exit 7 $1;; status) rh_status;; *) echo $"Usage: $0 {start | stop | restart | reload | status}" exit 2esac

Modify script operation permissions and add executable permissions

Chmod 755 / etc/init.d/redis

The above is all the contents of the article "how to write the redis startup management script". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Scripts management content permissions articles values interests guys buddies documents more source code knowledge industry information information channels paths channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Linux Shulou Technology Redmi Microsoft