Share the memcached shell startup and stop script

Source: Internet
Author: User
Tags stop script
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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.