Skip to content

Instantly share code, notes, and snippets.

@hustlijian
Created June 4, 2018 08:33
Show Gist options
  • Save hustlijian/47d9778e0912ebfb3acc7670e63f7f62 to your computer and use it in GitHub Desktop.
Save hustlijian/47d9778e0912ebfb3acc7670e63f7f62 to your computer and use it in GitHub Desktop.
monitor and restart
#!/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