In order to run a game server (minecraft) I start it by running this command in CentOS:
java -Xms512M -Xmx1G -jar minecraft_server.jar
But I have no idea how to stop this file from running. I assume it has it's own internal command but considering it might be started in background and running for a very long time, how can I stop this Java command?
Thank you.
You can use a combination of ps and kill to stop the particular process.
You would first do
ps -aux | grep minecraft
to get the process number - which is the second field, first number.Then you can issue
kill $PID
to send SIGTERM to the process and have it gracefully shutdown.You can use the following 2 files to start/stop service.jar
start.sh
stop.sh