Shell script implementation of memcached process monitoring _linux shell

Source: Internet
Author: User
Tags memcached

The Web server uses memcached, but does not know why memcached always hangs (basic 20 minutes ~ 50 minutes), causes some website page to visit the time error; When you define the log, you cannot see what ; Preliminary determination is related to the prior update of libevent. Because the online server, so first with the foot to make up for the next

#!/bin/sh 
pid= ' ps aux|grep-v grep|grep Memcached|awk ' {print $} ' 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 mainly temperature 2 knowledge points, one is awk, one is the conditional expression of if, of course, those single quotes, double quotes, special single quotes are annoying. Just a basic script, very vegetable, but can realize I want the function, first judge memcached process exists, if not exist then start memcached and overload Nginx.

Finally added to the system task, every 5 minutes to determine:

*/15 * * * */root/memcached.sh

Completed!

As for the if conditional expression, there are more, you can search the Internet to see, here is not repeated.

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.