Simple Debian 11 Minecraft Server – Part 3

Published on December 6, 2021 at 7:02 am by LEW

Minecraft ImageIntroduction

In the last post we had the Minecraft Server up and running. However there is one issue that needs to be resolved, and one feature that needs to be added.

Basically if you log out of the server, Minecraft stops. We will fix that by using the screen program we installed earlier. While we could do it by hand, we will write a bash script to simplify this process

And we want to start Minecraft when the server boots up. We will add that feature with a cron job.

Write a Startup Script

We are going to use the terminal multiplexer we installed earlier to run minecraft server in a detached window that is not reliant on you being logged into the server.

This two line script file will create a detached screen session and launch the minecraft server in it. So fire up your favorite text editor. I saved it as in the mindcraft home directory.

 screen -dm java -Xmx2048M -Xms1024M -jar server.A.jar nogui

The first line of this script uses the shebang (please just check the link) to identify the bourne shell.

The second line starts a new screen session in detached mode, with the command from last post running in the screen instance.

One more thing to do here, make the file executable. I used the chmod program to do this.

chmod ug+x

Now we can run the script to see if the server starts.


Ideally the results should be nothing as we started the server in a detached screen.  Assuming this is the only instance of screen running, to attach it we use the  command below and make sure server is running. Alternately try to connect.

screen –r

You should be looking at a display similar to what we saw in the last post. Please remember to detach the screen before logging out. To do this use control and a then d key presses.

Run On Startup

There is some variation between different distributions and versions of Linux on how to start a program at boot. We are going to get around theses variations by setting up a  CRON Job. To start the process enter the command below.

crontab -e

You may be asked to chose your text editor. After that, enter the below line at the bottom of the file. Note that your script path may vary from what I used, depending on your setup.

@reboot /home/minecraft/

Test the CRON job

Now perform a restart and validate the minecraft  server program is running  by logging into the minecraft world. You can also log back into the server and check if the it is running in a detached screen (see above).


That is it, we are done. Enjoy your Minecraft Server.

If this server will be exposed to unknown users, there are a few security things that you should attend to, like setting up a firewall. But that is beyond the scope of these posts.

Simple Debian 11 Minecraft Server – Part 1

Simple Debian 11 Minecraft Server – Part 2

Simple Debian 11 Minecraft Server – Part 3

JM says:

Great tutorial. I think everything worked except connection refused, but i think thats another issue. Thanks for this!

LEW says:

JM, can you tell me if “connection refused” is from trying to connect via ssh to the server? Or from trying to connect to the minecraft instance running on the server?


Justin says:

This is an excellent write-up in a world where there is frustratingly little information. Thank you!

Add New Comment

Your email address will not be published. Required fields are marked *