shell實戰之:用shell實現squid守護進程

來源:互聯網
上載者:User

shell實戰之:用shell實現squid守護進程 01用shell實現squid守護進程02每兩分鐘檢測一下squid服務狀態,如果squid服務不在了,則啟動,達到守護的目的03指令碼如下:04#!/bin/sh05#code by scpman06#mail:scpman@Live.com07#Blog:http://www.scpman.com08msgip="10.0.1.111"09IP=`cat /etc/rc.conf | grep -E "ifconfig_[em1|bce1]" | awk '{print "IP:"$2}'| sed -n 1p `10check_squid()11{12rs_flag=`ps uaxww | grep squid|grep -v grep | wc -l`13if [ "$rs_flag" -gt 0 ]14then15        echo 'squid server is running..'16        exit;17else18        echo 'squid server is not running...'19        /usr/local/squid/sbin/squid -z20        /usr/local/squid/sbin/squid -D21        /usr/bin/logger -p local1.info -h $msgip "the services: $IP squid will to start by watch_squid.sh "22        sleep 123        check_squid24fi25}26check_squid27每兩分鐘用定時實現,如果要1分鐘檢查一次,就是* * * * *了28定時如下29*/2 * * * * su - root -c "/usr/home/admin/mgr_shell/watch_squid.sh" 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.