Minecraft Java Edition – Is Sending SIGTERM to Minecraft Server Equal to Using /stop Command?

minecraft-java-editionminecraft-java-edition-server

I wonder if sending the SIGTERM signal to a minecraft server does save the world in the same way the /stop command does. I think that this could not be the case because the server doesn't write log messages that he is saving the world when it is killed.

Stopping by using the /stop command:

[19:53:26] [Server thread/INFO]: Done (3.986s)! For help, type "help" or "?"
/stop
[19:53:45] [Server thread/INFO]: Stopping the server
[19:53:45] [Server thread/INFO]: Stopping server
[19:53:45] [Server thread/INFO]: Saving players
[19:53:45] [Server thread/INFO]: Saving worlds
[19:53:45] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
[19:53:45] [Server thread/INFO]: Saving chunks for level 'world'/Nether
[19:53:45] [Server thread/INFO]: Saving chunks for level 'world'/The End
tim@minecraft:~/survival$

Stopping by sending SIGTERM:

[19:57:36] [Server thread/INFO]: Done (3.790s)! For help, type "help" or "?"
tim@minecraft:~/survival$

Best Answer

SIGTERM is just a generic signal that can be sent to any program to cause it to terminate. If the signal is not handled properly by the program, this could cause Minecraft to stop the server without saving the world.

According to issue MC-17244 on Mojang's Jira board, sending SIGTERM to the server should save the world, since the bug is marked as resolved.

Ultimately I think that sending the /stop command is the safest way to stop the server. I don't have the source code, so I don't know if /stop and the SIGTERM handling implemented in Minecraft do the same thing. But according to that bug ticket, it should be close to the same functionality.