腳本來檢查httpd的開啓或關閉,
#!/bin/bash
service=service_name
[email protected]
host=`hostname -f`
if (($(ps -ef | grep -v grep | grep $service | wc -l) > 0))
then
echo "$service is running"
else
/etc/init.d/$service start
if (($(ps -ef | grep -v grep | grep $service | wc -l) > 0))
then
subject="$service at $host has been started"
echo "$service at $host wasn't running and has been started" | mail -s "$subject" $email
else
subject="$service at $host is not running"
echo "$service at $host is stopped and cannot be started!!!" | mail -s "$subject" $email
fi
fi
如何使這個腳本在後臺運行,這樣它保持如果httpd的檢查服務處於開啓或關閉狀態,並在電子郵件發送時發送消息! (PS-:我不希望將腳本作爲CRONJOB)就像在後臺運行的守護進程一樣! 請幫忙創建檢查腳本的dameon如果httpd服務是打開還是關閉
你想要什麼樣的幫助?爲你寫代碼? –
你已經有了這個腳本,問題是「我如何在後臺運行它?」。 – Francesco
請檢查[如何編寫最小完整的可驗證示例](http://stackoverflow.com/help/how-to-ask) – sjsam