My Linux server Minecraft script

I like playing Minecraft on a PC more than on mobile even though I own both.  Further, I prefer to play on a server so that I can play with my kids even if I’m out of town.

I run the server side on a Virtual Private Server.  My first action is to run screen so the console can be detached, in case of internet issues.  I run the server as root, which is not strictly necessary, via sudo minecraft.  /usr/local/bin is part of my execution path.

One of the first lines of my minecraft script calls which allows me to have multiple server side worlds.  This allows me to run the family world most of the time, but allows me to have a private world as well.

I run minecraft_server.jar in a until do loop so that in the event of a server crash, I only have to wait 30 seconds before I can try to reconnect.  If I enter the “/stop” command at the console, the server exits cleanly and doesn’t restart.  This way I’m not running a server when I don’t expect player to be around.  The VPS should have 5GB of memory but I run other servers at the same time so I limit the game to 2GB.

The minecraft_server.jar points to the most recent server version.  I keep a copy of older versions just in case.




cd /usr/local/minecraft

./ $1
echo “Starting minecraft”
until java -Xmx2048M -Xms1024M -jar /usr/local/minecraft/minecraft_server.jar nogui
echo “Crashed… sleeping.”
sleep 15

echo “Clean quit”

Server select, as mentioned above, changes which world is loaded by the minecraft server.  The server automatically calls the server.properites file in the minecraft working directory.  I put the file in the world’s sub-directory and make a symbolic link from minecraft working directory to the world of interest.  The world’s directory is a parameter in the file. The “default” world is a symbolic link to the directory I expect to use most often.  Notice that if server_select is not given an argument,  “$1” will be an empty string.




if [ -z “$1″ ]

echo “Selecting $SERVER_NAME”

ln -snf “$SERVER_NAME/” .
ls -l




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s