月額480円〜の高速レンタルサーバー ColorfulBox

OpenShift自动重启脚本

//进入本地工程目录
.openshift/cron/minutely
//新建自动重启脚本
restart.sh

#复制这段代码到restart.sh

1#!/bin/bash
2export TZ='Asia/Shanghai'
3curl -I ${OPENSHIFT_APP_DNS} 2> /dev/null | head -1 | grep -q '200|301|302'
4s=$?
5if [ $s != 0 ];
6then
7echo "`date +"%Y-%m-%d %H:%M:%S"` down" >> ${OPENSHIFT_DATA_DIR}web_error.log
8let t=`date +"%M"`%5
9if [ $t -eq 0 ];
10then
11echo "`date +"%Y-%m-%d %H:%M:%S"` restarting…" >> ${OPENSHIFT_DATA_DIR}web_error.log
12/usr/bin/gear stop 2>&1 /dev/null
13/usr/bin/gear start 2>&1 /dev/null
14echo "`date +"%Y-%m-%d %H:%M:%S"` restarted!!!" >> ${OPENSHIFT_DATA_DIR}web_error.log
15fi
16else
17echo "`date +"%Y-%m-%d %H:%M:%S"` is ok" > ${OPENSHIFT_DATA_DIR}web_run.log
18fi

#复制这段代码到restart.sh

//使用ssh赋予脚本711权限

chmod 711 restart.sh

Published by

@XiaoKyun

双鱼男,过分热心的好人。