Shopping Cart (0)

Your cart is empty.

NewsWelcome to the future of PineRiver: new website, new domain and New Year's sale! Read more
Support

Introduction

Running a Minecraft server requires regular maintenance to ensure stable operation, minimal lag, and a good experience for players. Automating maintenance tasks can save you time and reduce the risk of downtime. In this guide, we'll walk you through how to automate your Minecraft server to keep it running smoothly.


1. Automatic backups

Why are backups important?

Whether you're managing a private server or a public community server, it's important to have regular backups to prevent data loss in the event of errors, corruption, or attacks.

How do you set up automatic backups?

Linux (Ubuntu/Debian) Backup Script:

  1. Create a backup folder:
    mkdir -p /home/minecraft/backups
    
  2. Create a backup script:
    nano /home/minecraft/backup.sh
    
    Insert the following code:
    #!/bin/bash
    timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
    tar -czf /home/minecraft/backups/minecraft_backup_$timestamp.tar.gz /home/minecraft/server
    
  3. Make the script executable:
    chmod +x /home/minecraft/backup.sh
    
  4. Schedule the script with cron-job:
    crontab -e
    
    Add this line to run the script daily at 3:00 a.m.:
    0 3 * * * /home/minecraft/backup.sh
    

For Windows users, a Windows Task Scheduler can be used to run a batch file with a similar backup process.


2. Automatic server restart

Why restart your server regularly?

Regular restarts free up memory and can prevent lag and instability.

To set up an automatic restart:

Linux (Ubuntu/Debian) Restart Script:

  1. Create a script:
    nano /home/minecraft/restart.sh
    
    Insert the following:
    #!/bin/bash
    screen -S minecraft -X stuff "say Serveren genstarter om 10 sekunder...\n"
    sleep 10
    screen -S minecraft -X stuff "stop\n"
    sleep 5
    cd /home/minecraft/server
    screen -dmS minecraft java -Xmx4G -Xms2G -jar server.jar nogui
    
  2. Make the script executable:
    chmod +x /home/minecraft/restart.sh
    
  3. Add cron job for restart at 4:00 a.m. every day:
    crontab -e
    
    Add this line:
    0 4 * * * /home/minecraft/restart.sh
    

For Windows, a batch file can be used with Task Scheduler to restart the server automatically.


3. Automatic updates to the Minecraft server

To keep your server secure and compatible with the latest features, it is important to update it regularly.

To set up an automatic update:

  1. Create a script:
    nano /home/minecraft/update.sh
    
    Insert the following code:
    #!/bin/bash
    cd /home/minecraft/server
    wget -O minecraft_server.jar https://launcher.mojang.com/v1/objects/latest-version.jar
    
  2. Make the script executable:
    chmod +x /home/minecraft/update.sh
    
  3. Schedule the script to run weekly:
    crontab -e
    
    Add this line:
    0 5 * * 1 /home/minecraft/update.sh
    

4. Automatic monitoring and alerts

If your server goes down, it is important to be notified immediately.

To set up an automatic monitoring service:

  1. Install monit:
    sudo apt install monit -y
    
  2. Edit the Monit configuration:
    sudo nano /etc/monit/monitrc
    
    Add the following:
    check process minecraft with pidfile /home/minecraft/server/server.pid
      start program = "/home/minecraft/start.sh"
      stop program = "/home/minecraft/stop.sh"
      if 3 restarts within 5 cycles then alert
    
  3. Restart Monit:
    sudo systemctl restart monit
    

5. Automatic lag optimization

To ensure a stable gaming experience, you should also optimize your server to minimize lag.

Recommended optimizations:

  • Use PaperMC instead of vanilla Minecraft for better performance.
  • Install LagAssist for automatic lag monitoring.
  • Reduce render distance in server.properties.
  • Remove inactive entities and mobs with ClearLag.

Final thoughts

By automating the maintenance of your Minecraft server, you ensure a stable and hassle-free experience for you and your players. With regular backups, automatic restarts, updates, and monitoring, you can focus on enjoying the game instead of dealing with technical issues.

If you want a more streamlined solution, PineRiver offers fully automated hosting services, so you don't have to worry about a thing. Start your Minecraft server today with the best hosting solution!

Are you ready to begin?

Create Your Own ServerAre you ready to begin?

Start your server today and we'll give you a 25% discount on your first server. Use code NEW25 at checkout.