歡迎您光臨本站 註冊首頁

腳本

←手機掃碼閱讀     火星人 @ 2014-03-24 , reply:0

下面是shell腳本 —————?
#!/bin/csh
#
# NAME
# keepitup.csh ? Keep demons up and running
#
# SYNOPSIS
# keepitup.csh
#
# DESCRIPTION
# If any of the following processes are down, then start them up
# again. This script can be run every few minutes from a crontab.
#
# AUTHOR
# Ken Stevens <kstevens@globeandmail.ca>
foreach daemon ( \
/opt/GIS/apps/EventDispatcher/scripts/EventDispatcher.pl \
/opt/GIS/apps/CatchFTP/scripts/ProcessFTP.pl \
/opt/GIS/apps/NewsHound/scripts/NewsHound.pl \
)
ps -e | fgrep `echo $daemon:t | cut -c1-8` > /dev/null
if ( $status > 0 ) then
echo Restarting $daemon
date
$daemon &
endif
end

備註:這個腳本的思路,就是在crontab定期運行的時候,檢測對應名稱的進程是否還存在,如果不存在,就重新啟動它
局限:對於那些啟動之後,detach當前終端session,最終以另外一個程序名運行的情況(比如,啟動腳本是apache22,最終進程名稱是httpd),需要額外處理。此外,對於啟動兩個相同名稱、不同配置文件的後台進程情況,也需要額外處理。

有沒有可以解釋一下這個腳本呢?

[火星人 ] 腳本已經有132次圍觀

http://coctec.com/docs/linux/show-post-143524.html