简体   繁体   中英

Auto Restart SH script on crash?

Hi there guys i have a server running a game I've created and it has three SH scripts that are required to run in separate terminals so what i wanna know is 2 things.

1:is there a way i can get a single script that i double click on and launch all three scripts to where i can see the shell (for Debugging)

2: Is there any way to have said scripts auto restart when they exit or crash? (for full automated access when the server is unattended by a dev)

Server Specs: 6gb ram 60gb SSD 6 core CPU Ubuntu 14.04 with vnc for desktop control

Here's a SH script for you.

running=1

finish()
{
    running=0
}

trap finish SIGINT

while (( running )); do
    // Execute the command here that starts your server.
    echo "Restarting server on crash.."
    sleep 5
done

You can run this script for each server in it's own screen . That way you can see the console output of each one. For example:

screen -S YOURUNIQUENAME -m THESCRIPTABOVE.sh

In order to detach from the screen, hit CTRL + A then CTRL + D. You can get back to the screen by using screen -x YOURUNIQUENAME

For a nice guide on using the screen command, see this article: http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/ . It even has a video to show how it's used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM