Created
June 4, 2018 08:33
-
-
Save hustlijian/47d9778e0912ebfb3acc7670e63f7f62 to your computer and use it in GitHub Desktop.
monitor and restart
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 | |
# 重试运行的命令 | |
echo $@ | |
MAX_REBOOT_TIMES=100 # 最大重启次数 | |
reboot_times=0 | |
while true ; do | |
$@ | |
let reboot_times=reboot_times+1 | |
echo $reboot_times | |
if [ $reboot_times -gt $MAX_REBOOT_TIMES ]; then | |
echo "max reboot times, exit" | |
exit -1 | |
fi | |
sleep 5 # 休眠下 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment