[英]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. 嗨,大家好,我有一个运行我创建的游戏的服务器,它具有三个SH脚本,这些脚本需要在单独的终端上运行,所以我想知道的是两件事。
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) 1:有没有办法我可以双击一个脚本并将所有三个脚本启动到我可以看到外壳的位置(用于调试)
2: Is there any way to have said scripts auto restart when they exit or crash? 2:有没有办法说脚本退出或崩溃时自动重启? (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 服务器规格:6GB RAM 60GB SSD 6核心CPU Ubuntu 14.04,带有用于桌面控制的vnc
Here's a SH script for you. 这是适合您的SH脚本。
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
. 您可以在其自己的
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
为了脱离屏幕,请按CTRL + A,然后按CTRL +D。您可以使用
screen -x YOURUNIQUENAME
返回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/ . 有关使用
screen
命令的指南,请参阅本文: http : //www.rackaid.com/blog/linux-screen-tutorial-and-how-to/ 。 It even has a video to show how it's used. 它甚至有一个视频来展示其用法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.