The following script:
#! /bin/sh## chkconfig:-45# Description: The memcached daemon is a network memory cache service.# PROCESSNAME:MEMCA ched# config:/etc/sysconfig/memcached# Source function Library-for other linux#. /etc/rc.d/init.d/functions# Source function library-for suse Linux. /lib/lsb/init-functionsport=11211user=root# Maximum number of connections, modify maxconn=1024# maximum amount of memory according to actual demand, Unit mcachesize=128options= ""
If [-f/etc/sysconfig/memcached];then ./etc/sysconfig/memcachedfi# Check that networking is Up.if ["$NETWORKING" = "No"]then exit 0fi
Retval=0prog= "memcached" Start () {echo-n $ "starting $prog:" # insure that/usr/local/memcached has proper permiss Ions chown $USER/usr/local/memcached/usr/local/memcached/bin/memcached-d-P $PORT-u $USER-M $CACHESIZE-C $MAX Conn-p/usr/local/memcached/memcached.pid $OPTIONS retval=$? echo [$RETVAL-eq 0] && touch/var/lock/subsys/memcached}stop () {echo-n $ "stopping $prog:" Killproc Memcached retval=$? echo if [$RETVAL-eq 0]; Then rm-f/var/lock/subsys/memcached rm-f/usr/local/memcached/memcached.pid Fi}restart () {Stop start}# See how we were Called.case "$" in start) start; stop) stop;; status) status memcached;; restart|reload) restart;; Condrestart) [-f/var/lock/subsys/memcached] && Restart | | : ;; *) echo $ "Usage: $ Start|stop|status|restart|reload|condrestart}" Exit 1esacexit $?
Remove the Chinese part of the paragraph above, just to make comments in the code. memcached location to your own location
Edit this code in the/etc/init.d/memcached file
Then execute the script:
# chmod 755/etc/init.d/memcached# chkconfig--add memcached# chkconfig memcached on# Service memcached start
If the above is successful, reboot the system to see if the memcached has been booted with the system.
Set memcached self-boot on Linux