Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis startup script, boot automatically

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

# chkconfig: 2345 90 10

# description: Redis is a persistent key-value database

PATH=$PATH:/usr/local/redis/bin:/sbin:/usr/bin:/bin

REDISPORT=6379

EXEC=/usr/local/redis/bin/redis-server

REDIS_CLI=/usr/local/redis/bin/redis-cli

PASS=chbin123

PIDFILE=/var/run/redis_6379.pid

CONF= "/ usr/local/redis/etc/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

If ["$?" = "0"]

Then

Echo "Redis is running..."

Fi

Stop)

If [!-f $PIDFILE]

Then

Echo "$PIDFILE does not exist, process is not running"

Else

PID=$ (cat $PIDFILE)

Echo "Stopping..."

$REDIS_CLI-a $PASS-p $REDISPORT SHUTDOWN

While [- x ${PIDFILE}]

Do

Echo "Waiting for Redis to shutdown..."

Sleep 1

Done

Echo "Redis stopped"

Fi

Restart | force-reload)

${0} stop

${0} start

*)

Echo "Usage: / etc/init.d/redis {start | stop | restart | force-reload}" > & 2

Exit 1

Esac

-

Add redis service boot startup:

Chmod + x / etc/init.d/redis

Start the redis service:

Service redis start

Check whether the service is started

Ps-ef | grep redis

Netstat-anptu | grep 6379

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report