Note: To use this shell, you must first successfully create the memcache environment 1 and create the memcached file and permission [email protected] ~] # Touch/etc/init. d/memcached [[email protected] ~] # Chmod + x/etc/init. d/memcached2 write the memcached Shell management script VI/etc/init. d/memcached #! /Bin/bash # memcached-this shell script takes care of starting and stopping memcached. # chkconfig:-90 10 # Description: memcache provides fast memory based storage. # processname: memcachedmemcached_path = "/usr/local/bin/memcached" memcached_pid = "/var/run/memcached. PID & quot; memcached_memory = & quot; 1024 & quot; # source function library .. /etc/rc. d/init. d/functions [-x $ memcached_path] | exit 0 retval = 0 prog = "memcache D "# Start daemons. Start () {if [-e $ memcached_pid-! -Z $ memcached_pid]; Then ECHO $ prog "already running .... "Exit 1 fi echo-N $" Starting $ prog "# single instance for all caches $ memcached_path-M $ memcached_memory-l 0.0.0.0-P 11211-u root-D-p $ memcached_pid retval =$? [$ Retval-EQ 0] & {touch/var/lock/subsys/$ prog success $ "$ prog"} echo return $ retval} # Stop daemons. stop () {echo-N $ "Stopping $ prog" killproc-D 10 $ memcached_path echo [$ retval = 0] & Rm-F $ memcached_pid/var/lock/subsys/$ prog retval = $? Return $ retval} # see how we were called. Case "$1" in START) Start; stop) Stop; Status) Status $ prog retval = $?; Restart) Stop start; *) echo $ "Usage: $0 {START | stop | status | restart} "Exit 1 esacexit $ retval ############## the following two configurations in this script can be used according actual configuration ############# memcached_path = "/usr/local/bin/memcached" # memcached_memory = "1024" 3 "system Service chkconfig -- add memcached chkconfig memcached on
4 test (try it)
<p>service memcached start|stop|status|restart </p>