/etc/init.d# ./redis-server start

 

 

root@ubuntu:/etc/init.d# ll
total 256
drwxr-xr-x  2 root root 4096 May  4 23:24 ./
drwxr-xr-x 87 root root 4096 May  4 23:24 ../
-rwxr-xr-x  1 root root 6250 Oct  4  2016 apparmor*
-rwxr-xr-x  1 root root 1275 Jan 19  2016 bootmisc.sh*
-rwxr-xr-x  1 root root 3807 Jan 19  2016 checkfs.sh*
-rwxr-xr-x  1 root root 1098 Jan 19  2016 checkroot-bootclean.sh*
-rwxr-xr-x  1 root root 9353 Jan 19  2016 checkroot.sh*
-rwxr-xr-x  1 root root 1343 Apr  4  2016 console-setup*
-rwxr-xr-x  1 root root 3049 Apr  5  2016 cron*
-rwxr-xr-x  1 root root 2813 Dec  1  2015 dbus*
-rw-r--r--  1 root root  967 May  4 23:24 .depend.boot
-rw-r--r--  1 root root  624 May  4 23:24 .depend.start
-rw-r--r--  1 root root  623 May  4 23:24 .depend.stop
-rwxr-xr-x  1 root root 1105 Mar 15  2016 grub-common*
-rwxr-xr-x  1 root root 1336 Jan 19  2016 halt*
-rwxr-xr-x  1 root root 1423 Jan 19  2016 hostname.sh*
-rwxr-xr-x  1 root root 3809 Mar 12  2016 hwclock.sh*
-rwxr-xr-x  1 root root 2372 Apr 11  2016 irqbalance*
-rwxr-xr-x  1 root root 1804 Apr  4  2016 keyboard-setup*
-rwxr-xr-x  1 root root 1300 Jan 19  2016 killprocs*
-rwxr-xr-x  1 root root 2087 Dec 20  2015 kmod*
-rwxr-xr-x  1 root root 7768 Jun 30  2014 mongodb*
-rwxr-xr-x  1 root root  703 Jan 19  2016 mountall-bootclean.sh*
-rwxr-xr-x  1 root root 2301 Jan 19  2016 mountall.sh*
-rwxr-xr-x  1 root root 1461 Jan 19  2016 mountdevsubfs.sh*
-rwxr-xr-x  1 root root 1564 Jan 19  2016 mountkernfs.sh*
-rwxr-xr-x  1 root root  711 Jan 19  2016 mountnfs-bootclean.sh*
-rwxr-xr-x  1 root root 2456 Jan 19  2016 mountnfs.sh*
-rwxr-xr-x  1 root root 4771 Jul 19  2015 networking*
-rwxr-xr-x  1 root root 1581 Oct 15  2015 ondemand*
-rwxr-xr-x  1 root root 4987 Mar  2 05:02 php7.0-fpm*
-rwxr-xr-x  1 root root 1366 Nov 15  2015 plymouth*
-rwxr-xr-x  1 root root  752 Nov 15  2015 plymouth-log*
-rwxr-xr-x  1 root root 1192 Sep  5  2015 procps*
-rwxr-xr-x  1 root root 6366 Jan 19  2016 rc*
-rwxr-xr-x  1 root root  820 Jan 19  2016 rc.local*
-rwxr-xr-x  1 root root  117 Jan 19  2016 rcS*
-rw-r--r--  1 root root 2427 Jan 19  2016 README
-rwxr-xr-x  1 root root  661 Jan 19  2016 reboot*
-rwxr-xr-x  1 root root 1750 Dec 19  2015 redis-server*
-rwxr-xr-x  1 root root 4149 Nov 23  2015 resolvconf*
-rwxr-xr-x  1 root root 4355 Jul 10  2014 rsync*
-rwxr-xr-x  1 root root 2796 Feb  3  2016 rsyslog*
-rwxr-xr-x  1 root root 3927 Jan 19  2016 sendsigs*
-rwxr-xr-x  1 root root  597 Jan 19  2016 single*
-rw-r--r--  1 root root 1087 Jan 19  2016 skeleton
-rwxr-xr-x  1 root root 4077 Apr 27  2016 ssh*
-rwxr-xr-x  1 root root 6087 Apr 12  2016 udev*
-rwxr-xr-x  1 root root 2049 Aug  7  2014 ufw*
-rwxr-xr-x  1 root root 2737 Jan 19  2016 umountfs*
-rwxr-xr-x  1 root root 2202 Jan 19  2016 umountnfs.sh*
-rwxr-xr-x  1 root root 1879 Jan 19  2016 umountroot*
-rwxr-xr-x  1 root root 3111 Jan 19  2016 urandom*
-rwxr-xr-x  1 root root 1306 Dec 16 07:40 uuidd*
root@ubuntu:/etc/init.d# cat redis-server
#! /bin/sh
### BEGIN INIT INFO
# Provides:             redis-server
# Required-Start:       $syslog $remote_fs
# Required-Stop:        $syslog $remote_fs
# Should-Start:         $local_fs
# Should-Stop:          $local_fs
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    redis-server - Persistent key-value db
# Description:          redis-server - Persistent key-value db
### END INIT INFO


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/redis-server
DAEMON_ARGS=/etc/redis/redis.conf
NAME=redis-server
DESC=redis-server

RUNDIR=/var/run/redis
PIDFILE=$RUNDIR/redis-server.pid

test -x $DAEMON || exit 0

if [ -r /etc/default/$NAME ]
then
        . /etc/default/$NAME
fi

. /lib/lsb/init-functions

set -e

Run_parts () {
        if [ -d /etc/redis/${NAME}.${1}.d ]
        then
                su redis -s /bin/sh -c "run-parts --exit-on-error /etc/redis/${NAME}.${1}.d"
        fi
}

case "$1" in
  start)
        echo -n "Starting $DESC: "
        mkdir -p $RUNDIR
        touch $PIDFILE
        chown redis:redis $RUNDIR $PIDFILE
        chmod 755 $RUNDIR

        if [ -n "$ULIMIT" ]
        then
                ulimit -n $ULIMIT
        fi

        Run_parts pre-up

        if start-stop-daemon --start --quiet --oknodo --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
        then
                Run_parts post-up
                echo "$NAME."
        else
                echo "failed"
        fi
        ;;
  stop)
        echo -n "Stopping $DESC: "

        Run_parts pre-down

        if start-stop-daemon --stop --retry forever/TERM/1 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
        then
                Run_parts post-down
                echo "$NAME."
        else
                echo "failed"
        fi
        rm -f $PIDFILE
        sleep 1
        ;;

  restart|force-reload)
        ${0} stop
        ${0} start
        ;;

  status)
        status_of_proc -p ${PIDFILE} ${DAEMON} ${NAME}
        ;;

  *)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}" >&2
        exit 1
        ;;
esac

exit 0
root@ubuntu:/etc/init.d# redis-server stop
16043:C 05 May 00:16:19.728 # Fatal error, can't open config file 'stop'
root@ubuntu:/etc/init.d# ./redis-server stop
[ ok ] Stopping redis-server (via systemctl): redis-server.service.
root@ubuntu:/etc/init.d# ./redis-server start
[ ok ] Starting redis-server (via systemctl): redis-server.service.
root@ubuntu:/etc/init.d#

 

posted @ 2017-05-05 15:18  papering  阅读(466)  评论(0编辑  收藏  举报