Skip to content

Instantly share code, notes, and snippets.

@markalanevans
Created November 3, 2011 03:22
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save markalanevans/1335694 to your computer and use it in GitHub Desktop.
Save markalanevans/1335694 to your computer and use it in GitHub Desktop.
Simple RedHat Redis init.d script
#!/bin/sh
#
# redis Startup script for Redis Server
#
# chkconfig: - 90 10
# description: Redis is an open source, advanced key-value store.
#
# processname: redis-server
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/opt/redis/redis-server
REDIS_CLI=/opt/redis/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/opt/redis/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo -n "$PIDFILE exists, process is already running or crashed\n"
else
echo -n "Starting Redis server...\n"
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo -n "$PIDFILE does not exist, process is not running\n"
else
PID=$(cat $PIDFILE)
echo -n "Stopping ...\n"
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
esac
@gembin
Copy link

gembin commented Apr 5, 2013

tested not working, PIDFILE is not created

@atejeda
Copy link

atejeda commented Aug 7, 2013

after line 28, echo $! > $PIDFILE will create the PID file.

@Petrie
Copy link

Petrie commented Feb 24, 2014

after line 43, /bin/rm $PIDFILE will remove pdifile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment