systemd is the default init system for most modern distros.
You need to create a service file in
[Unit]Description=LinuxGSM Teamspeak3 ServerAfter=network-online.targetWants=network-online.target[Service]Type=forkingUser=ts3serverWorkingDirectory=/home/ts3serverExecStart=/home/ts3server/ts3server startExecStop=/home/ts3server/ts3server stopRestart=noRemainAfterExit=yes #Assume that the service is running after main process exits with code 0[Install]WantedBy=multi-user.target
Replace the user and paths to fit your setup.
You need to reload the systemd-daemon once to make it aware of the new service file by
Now you can do
systemctl start ts3server # Start the serversystemctl stop ts3server # Stop the serversystemctl enable ts3server # Enable start on bootsystemctl disable ts3server # Disable start on boot
The crontab will allow you to create cronjobs that allow you to run a command on a set time or on boot. The below examples uses
@reboot that will run a command on boot.
@reboot '/home/username/gameserver monitor' > /dev/null 2>&1
note: Most admins will also have a timed monitor cronjob configured. If you do not want to have extra cronjobs the timed monitor will also start a server but with a timed delay.
After a reboot, any game server that has a "started" status will be started on boot. Servers that were manually stopped will remain stopped.
crontab -e@reboot su - username -c '/home/username/gameserver monitor' > /dev/null 2>&1
Start a game server unconditionally, even if you manually stopped a server.
crontab -e@reboot su - username -c '/home/username/gameserver start' > /dev/null 2>&1
To learn more, see Start-Stop-Restart
rc.local is another method to run scripts on boot. Any commands added to the rc.local file will run on boot.
nano /etc/rc.localsu - username -c '/home/username/gameserver start'