Shell script monitoring memcached

Source: Internet
Author: User
I haven't written any technical articles about my cainiao growth for a long time. I will post an article today. The WEB server uses memcached, but I don't know why memcached is always suspended (generally 20 minutes ~ 50 minutes or so), causing some website pages to go wrong during access; after defining the log, you cannot find anything to view the log; preliminary judgment due to the previous libevent update

I haven't written any technical articles about my cainiao growth for a long time. I will post an article today. The WEB server uses memcached, but I don't know why memcached is always suspended (generally 20 minutes ~ 50 minutes or so), causing some website pages to go wrong during access; after defining the log, you cannot find anything to view the log; preliminary judgment due to the previous libevent update

I haven't written any technical articles about my cainiao growth for a long time. I will post an article today.

The WEB server uses memcached, but I don't know why memcached is always suspended (generally 20 minutes ~ About 50 minutes), causing some website pages to go wrong during access. After defining the log, you cannot find anything in the log. It is preliminarily determined that it is related to the previous libevent update. Because the online server is used, you can use the script to make up for it.

#!/bin/sh
pid=`ps aux|grep -v grep|grep memcached|awk '{print $2}'`
memcached=`/usr/local/memcached/bin/memcached -u www &`
nginx=`/usr/local/nginx/sbin/nginx -s reload &`
if [ -z "$pid"]
then
echo $memcached
echo $nginx
fi

The above script has two knowledge points: awk and if. Of course, single quotes, double quotation marks, and special single quotes are also annoying. It's just a BASIC script. It's a good dish, but it can implement the functions I want. First, determine whether the memcached process exists. If it doesn't exist, start memcached and reload nginx.

Finally, it is added to the system task and determined every 5 minutes:

*/15 */root/memcached. sh

Finished!

For more information about the if condition expressions, go to the Internet to find them.

Original article, reprinted Please note:Reprinted from Clover

Link:Http://www.anjing.me/1463.html

Special statement: the reproduction of a commercial website must be approved by the author; otherwise, it shall be deemed as infringement!

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.