Set memcached self-boot on Linux

Source: Internet
Author: User

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

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.