1. Install screen
sudo apt-get install screen
2. Start your minecraft server using screen
# you can use whatever you want for the name, but don't forget the "s!
sudo screen -S "MC Server"
3. Now you can start your server (you can start whatever you want, it'll run until you close the screen "MC Server") If you have a bash script you can start it using this:
./your_minecraft_server_bash.sh
If you don't have a bash script you can start it using this:
sudo java -Xmx512M -Xms512M -jar mcserver.jar
Don't close the ssh yet! 4. Now you can close the screen
Press CTRL + A + D to close it.
now you can close the ssh connection. How to open it again?
sudo screen -r
or
screen -x number.nameofthescreen