[Unit] Description=Minecraft Server Documentation= Wants=network.target After=network.target [Service] User=nots Group=nots Restart=on-failure Type=forking WorkingDirectory=/srv/minecraft/server/ # Use 1024 lines of history, start in detatched mode, and set session name to minecraft. ExecStart=/usr/bin/screen -h 1024 -dmS minecraft ./startup.sh # Send 'stop' to the server console ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff \"say server shutting down in 30 seconds...\"\015' ExecStop=/bin/sleep 30 ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff \"stop\"\015' # Waid for PID to die, otherwise it's killed. ExecStop=/bin/bash -c "while ps -p $MAINPID > /dev/null; do /bin/sleep 1; done" [Install] WantedBy=multi-user.target