Interactive Services with Systemd
- /etc/systemd/system/minecraft-server.service
[Unit] Description=Minecraft Server [Service] User=minecraft Group=minecraft SyslogIdentifier=minecraft.service ExecStart=/usr/bin/tmux -S /home/minecraft/minecraft.tmux new -s minecraft -d 'java -jar minecraft-server.jar ....................' ExecStop=/usr/bin/tmux -S /home/minecraft/minecraft.tmux kill-server Type=forking WorkingDirectory=/home/minecraft/server Restart=always RestartSec=30s KillSignal=SIGINT TimeoutStartSec=10 TimeoutStopSec=10 [Install] WantedBy=multi-user.target
To connect to the interactive service, sudo -u minecraft -H – tmux -S /home/minecraft/minecraft.tmux attach -t minecraft