Disable the service through network connection in unbuntu #! /Bin/bash # specify ip address = 192.168.1.1 # specify the crm directory CRMDIR =/home/huchy/crm-ehr-20120522-deploy/# specify the user's password www.2cto.com PASSWORD_USER = 123456 # define flagPing = 0 flagStart = 0 flagMysql = 0 flagMemcached = 0 # Set the ping timeout value, query results, if a correct response is received, it indicates location 1 for line in 'Ping-c2-w 10 $ IP | grep "64 bytes from $ ip" 'Do flagPing = 1 done # view crm Service enabled or not, once started, set the flag to 1 for line in 'pstree | grep "java" 'Do flagStart = 1 done # Check whether the mysql service has been started, once started, set the flag to 1 for line in 'pstree | grep "mysql" 'Do flagMysql = 1 done # Check whether the memcached service is started with memcached, once started, set the flag to 1 for line in 'pstree | grep "memcached-d" 'Do flagMemcached = 1 done www.2cto.com echo "*********** * ************************** "echo" $ {flagPing} "echo" $ {flagStart} "echo" $ {flagMysql} "echo" $ {flagMemcached} "echo "********************* * ***************** "# If the flag bit is 1, it is normal operation, 0 indicates a network failure. if [$ flagPing = 0] then echo "$ IP failed" if [$ flagStart = 1] then cd $ {CRMDIR }. /stopofbiz. sh fi if [$ flagMysql = 1] then echo $ PASSWORD_USER | sudo-S service mysql stop fi echo $ PASSWORD_USER | sudo-S kill-9 'ps-ef | grep memcached | grep-v "grep" | awk '{print $2} ''else echo" $ IP success "if [$ flagMysql = 0] then echo $ PASSWORD_USER | sudo-S service mysql start fi if [$ flagStart = 0] then www.2cto.com cd $ {CRMDIR }. /startofbiz. sh fi if [$ flagMemcached = 0] then echo $ PASSWORD_USER | sudo-S service memcached stop memcached-d fi # echo $ PASSWORD_USER | sudo-S service mysql start # echo $ PASSWORD_USER | sudo-S service memcached stop # pingshizhe by memcached-d