這範例為判斷httpd目前的執行數量,如果執行數量超過100將進行重啟動作。
程式碼參考如下:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if httpd server | |
restarth() | |
{ | |
service httpd restart | |
} | |
httpd=$(ps aux | grep httpd | wc -l) | |
if (($httpd >= 100)); | |
then | |
echo "Warring" | |
restarth | |
else | |
echo "Normal" | |
exit | |
fi |
沒有留言:
張貼留言