Shell scripts for Linux admin memcached

Source: Internet
Author: User
Tags memcached

If memcached has been installed in Linux and is deployed to the/usr/local/memcached path, next we will begin to install service management scripts for it to start and stop.

First of all, through VI in the/ETC/RC.D/INIT.D path to create a new script file named memcached, the command is as follows:

The code is as follows Copy Code

Vi/etc/rc.d/init.d/memcached

Then, write the shell script to it as follows:

The code is as follows Copy Code

#!/bin/sh
#
# chkconfig:2345 90 50
# description:memcached Service Daemon
#
# processname:memcached
#
# Source function library.
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
#[${networking} = ' No '] && exit 0
#[-r/etc/sysconfig/dund] | | Exit 0
#. /etc/sysconfig/dund
#[-Z "$DUNDARGS"] && exit 0

Memcached= "/usr/local/memcached/bin/memcached"

Start ()
{
Echo-n $ "Starting Memcached:"
Daemon $MEMCACHED-u daemon-d-M 32-l 127.0.0.1-p 11211-c 256-p/tmp/memcached.pid
Echo
}
Stop ()
{
Echo-n $ "Shutting down Memcached:"
Killproc memcached
Echo
}

[f $MEMCACHED] | | Exit 1
# How we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart)
Stop
Sleep 3
Start
;;
*)
echo $ "Usage: $ {Start|stop|restart}"
Exit 1
Esac
Exit 0

After saving exit VI, execute the following command to install the script

The code is as follows Copy Code

chmod 777/etc/rc.d/init.d/memcached
Chkconfig--add memcached
Chkconfig--level 235 memcached on

You can then check to see if the installation was successful by using the following command

  code is as follows copy code

Chkconfig- List | grep memcached
Service memcached start
Service memcached Stop
Service memcached restart

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.