I have a script with this name : Run.sh
I run this script with this command :
./run.sh
I don’t like stop this script but this script Suddenly stops and need run again.
I need a script to check it , if my run.sh stopped , run it again.
this is run.sh codes:
#!/usr/bin/env bash install() { sudo apt-get update sudo apt-get upgrade } if [ "$1" = "install" ]; then install else if [ ! -f ./tg/tgcli ]; then echo "tg not found" echo "Run $0 install" exit 1 fi #sudo service redis-server restart #./tg/tgcli -s ./bot/bot.lua -l 1 -E $@ ./tg/tgcli -s ./bot/bot.lua $@ fi
And i want run this script at boot (with screen or tmux) if my server restart
i have Ubuntu 16.04 version
Thank you Ljm Dullaart
Can you help me about this ?
Advertisement
Answer
You should not need to run the complete bash script again. Changing
./tg/tgcli -s ./bot/bot.lua $@
to
while :; do ./tg/tgcli -s ./bot/bot.lua $@ done
will restart bot.lua everytime it exits.