[英]Minecraft Linux Server | Start.sh problem
I have a Minecraft Server running on Linux.我有一个在 Linux 上运行的 Minecraft 服务器。 I use to start the server, a start.sh file with following content: (This content starts a screen session and the minecraft server)
我用来启动服务器,一个start.sh文件,内容如下:(这个内容启动一个屏幕session和minecraft服务器)
screen -S {ScreenSession} java -Xmx2G -Xms2G -jar spigot-1.18.1.jar
If I use /restart ingame, the screen session will end and the server won't start.如果我使用 /restart ingame,屏幕 session 将结束,服务器将无法启动。 So I have to go into the Linux Server and start the Minecraft Server again.
所以我必须将 go 插入 Linux 服务器并再次启动 Minecraft 服务器。
My question:我的问题:
How can I make it so, if I use /restart that the server will restart with a active screen session.我怎样才能做到这一点,如果我使用 /restart 服务器将重新启动并显示活动屏幕 session。
If have tried many things.如果尝试了很多东西。 I hope someone can help me, ~Kitty Cat Craft
我希望有人可以帮助我,~Kitty Cat Craft
There is multiple way to achieve what you want.有多种方法可以实现您想要的。
If you have lot of servers, you can use a quick bash script with an auto restart like that:如果你有很多服务器,你可以使用一个快速的 bash 脚本,像这样自动重启:
#!/bin/sh
while true
do
java -Xmx2G -Xms2G -jar spigot-1.18.1.jar --nogui
sleep 5
done
When you will stop, it will wait 5 seconds then restart.当您停止时,它将等待 5 秒钟然后重新启动。
With this, you can use: screen -dmS <screenName> sh myScript.sh
which will run the script into another screen.有了这个,您可以使用:
screen -dmS <screenName> sh myScript.sh
将脚本运行到另一个屏幕。 It's usefull when you run it from a script which run lot of server, like that:当您从运行大量服务器的脚本运行它时,它很有用,如下所示:
screen -dmS srv1 sh srv1.sh
screen -dmS srv2 sh srv2.sh
screen -dmS srv3 sh srv3.sh
You can also, if you have only one server, just firstly use screen -S screenName
.如果您只有一台服务器,您也可以先使用
screen -S screenName
。 Then, when you are in the screen, run the script that restart automatically (the script that I gave at first).然后,当您在屏幕中时,运行自动重启的脚本(我最初给出的脚本)。
Also, prefer use /stop than /restart, because spigot will try to find the script.此外,更喜欢使用 /stop 而不是 /restart,因为 spigot 会尝试查找脚本。 And if it success, it will run a second time the same script, and so will have ghost process.
如果成功,它将第二次运行相同的脚本,因此会有幽灵进程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.