I've got a (modded) Minecraft server running in a tmux session on an Ubuntu 18.04 server. What might be a good way to get it to shut down gracefully and then relaunch daily at, say, 05:00 in the morning?
So, in the tmux window, I am running a command like the following:
while true; do java -Xmx15G -Xms15G -jar forge-1.14.4-28.2.0.jar nogui; sleep 120; done
This launches the Minecraft server, and relaunches it after a couple of minutes if it crashes. But in order to optimise performance, I would like the Minecraft server to shut down at, say, 05:00 in the morning gracefully, as it would with the Minecraft server command
/stop, and then to restart. How might this be done?
Is there some sleep command for the server that could, on launch, cause the server to
/stop after 24 hours, and then my little loop script restarts it? Is there a way to tell the server to stop when it detects there are no users?