1
So, I want to create a batch file for my Minecraft Server to startup and then restart the server at the end of each day (midnight, preferably, but 24-hour period works as well)
This is my startup batch, which calls other batch files to open and start the servers individually:
start cmd /k call BungeeStartup.bat
start cmd /k call HUBStartup.bat
start cmd /k call PvEStartup.bat
start cmd /k call PvPStartup.bat
start cmd /k call MinigamesStartup.bat
start cmd /k call TownyStartup.bat
start cmd /k call SecQStartup.bat
And each "Startup.bat" calls to run the server like this:
D:
cd Minecraft 1.12 Server Files
cd BungeeCord <-- and each it's respective server, of course, so I don't have to type it all out again
RUNGEE.bat
And, finally, the RUN.bat files look like this:
java -jar -Xmx350M spigot-1.12.2.jar -o true
And that starts all of my servers up in different command prompts. But the issue is, there's no way (that I know of) with this to end the servers without me manually typing /stop into each command prompt server, and then 'exit' into each command prompt again to exit it. Then I have re-execute the batch file manually as well.
So, my questions are:
- How do I (with the batch files) end each server, and then each command prompt window, without doing it manually
- How do I re-start them automatically after they exited.
- AND how to get this specifically to happen once every 24 hours (or, preferably at midnight each night)
EDIT:
So, to clarify how the Minecraft server works, I'm adding this edit.
When you startup a server, obviously it runs the server and everything and people can connect and play. It has a command prompt that you use to execute commands and see information and all that. In order to properly shut-down the server to where it saves everything and doesn't corrupt files, you type 'stop' into the command prompt. Then it exits out of the server and normally would exit the command prompt for you to re-open as willing. Then, with the batch files I have set up, it doesn't just exit the command prompt after typing 'stop', it returns you to the directory for you to continue using the command prompt as if it's not running the server anymore (because it isn't), and you have to type 'exit' to close the command prompt.
@FireDragon Okay, for the
timeout /t %StartPauseSec%
line you can make it be::timeout /t %StartPauseSec%
to comment it out and then run without it to see if it works without that or not. If it works, then you can remove or comment out the::SET StartPauseSec=10
line as well. I couldn't fully test these processes on my side but having a small wait period for certain things never hurts and usually always helps me for the things I automate with these type of solutions but I don't have Mine Craft server on my side to fully test. – Pimp Juice IT – 2018-07-11T22:03:52.110What I could do is schedule each event after the other is supposedly finished, but I'd rather not have to do it that way – Fire Dragon – 2018-07-11T22:45:19.733
Alright, well with my testing this, it closes BungeeCord, closes the HUB, and the re-opens the HUB, closes it, opens a new PvE without closing the already-existing one, closes it, and does the same for all the other servers, ending with SecQ but not closing out of it. – Fire Dragon – 2018-07-13T14:07:31.237
So I took a video of what happens exactly, and it also shows the setup and batch file codes I have and stuff. How can I share it with you? – Fire Dragon – 2018-07-13T19:53:36.133
Also, it's one screen just so you know – Fire Dragon – 2018-07-13T20:05:03.840
Ok cool. Here's the video I don't click on anything after starting the Master Kill.bat file until you see where I accidentally hit the Windows key.
– Fire Dragon – 2018-07-13T21:47:13.470Ok. Before, I had the 10 second in it and it was doing the same thing. I just took it out so I could see what was happening faster – Fire Dragon – 2018-07-13T23:38:26.400
Just tested it, it's doing the same thing. Although to note: in your code there's a space on line 25 before StopApp and after the quotation, remove it because it makes the stopping process not work, as it types it into the console. But yeah, it ends BungeeCord, exits the console, re-starts BungeeCord, then types stop into BungeeCord, and then after that it focuses on HUB – Fire Dragon – 2018-07-13T23:47:33.643
I think it would work better if it exited them all first, then attempted to restart them afterwards. – Fire Dragon – 2018-07-13T23:49:35.607
Alright, well, it works perfectly for BungeeCord, HUB, and PvE. Then, it jumps to SecQ, 'enters', then types 'stop' without entering, then goes to PvP and does the same thing and just gets weird from there but does basically the same stuff. However, it does continue to start all the servers back up again. It's just that some of them didn't get closed so it still didn't work properly – Fire Dragon – 2018-07-14T00:49:48.117
At the end, BungeeCord, HUB, and PvE, exit and restart perfectly. Then, SecQ had nothing happen to it except enter was pressed once, PvP has enter pressed and then 'stop' written in, but enter is not pressed again, and Minigames has the same thing except 'stopstop' is what was typed
I have to go to work now so I won't be able to respond for a while – Fire Dragon – 2018-07-14T00:51:49.337
Oh and Towny worked fine, I think (don't quote me on that) gotta go – Fire Dragon – 2018-07-14T00:52:56.013