##設定dump檔案大小的限制,咱這,無限制ulimit -c unlimitedcd /home/linbc/build/bin#檢查一下dump檔案夾是否存在不存在則建立if [ ! -d ../dumpfile ]then echo "create dumpfile fold" mkdir ../dumpfilefi#尋找
my
_app1,是否存在(咱們不可能每次都重啟這個進程,比如在我這個情境,要app1進程存在,我才會繼續啟動)if [ -z `pgrep
my
_app1` ]then echo "my_app1 not running!" exitfi#尋找my_app2是否存在,不存在則啟動if [ -z `pgrep my_app2` ]then echo "my_app2 not running!" #備份dump檔案,我在這個路徑下弄了個檔案夾用於存放dump檔案 app2_pid=`tail -1 ../dumpfile/app2.pid` if [ -n $app2_pid -a -e "core.${app2_pid}" ] then echo "backup dumpfile,move core.${app2_pid} ../dumpfile/centd.core.${app2_pid}" mv "core.${app2_pid}" "../dumpfile/app2.core.${app2_pid}" fi echo "start the app2 server" nohup ./my_app2 -c my_app2.conf > _app2.out 2>&1 & #將進程號存下來,用來重新命名dump檔案 pgrep my_app2 >> ../dumpfile/app2.pidficd ${OLDPWD}
然後就可以在shell
crontab –e
寫入
0-59/5 * * * * /home/linbc/bin/check_the_process
每五分鐘檢查一下