#!/bin/bash # Minecraft Server startup script using screen # Check if server is already running if screen -list | grep -q "mcs"; then echo "Server is already running! Type screen -r mcs to open the console" exit 1 fi # Switch to server directory cd /home/minecraft/ # Back up server if [ -d "world" ]; then echo "Backing up server (to minecraft/backups folder)" tar --exclude='backups' --exclude='logs' --exclude='server.jar' -pzcf backups/$(date +%Y.%m.%d.%H.%M.%S).tar.gz * fi echo "Starting Minecraft server. To view window type screen -r mcs." echo "To minimize the window and let the server run in the background, press Ctrl+A then Ctrl+D" screen -dmS mcs java -Xms1G -Xmx3G -XX:+ParallelRefProcEnabled -XX:+DisableExplicitGC -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=30 -XX:G1HeapRegionSize=8M -XX:+PerfDisableSharedMem -jar /home/minecraft/server.jar nogui