How to start teamspeak server on reboot as specific user
Solution 1
Found this solution:
crontab -e
i
@reboot /opt/teamspeak3-server_linux-x86/ts3server_startscript.sh restart
<esc>
:wq
Solution 2
If you do not require root
privileges at all to start the server, you can use something like
sudo -u <username> ./opt/teamspeak3-server_linux-x86/ts3server_startscript.sh start
to start it as user <username>
.
This command line must be placed in a file that is executed during startup.
IIRC there is a file for local stuff named somewhat like 99-local
in /etc/init.d/
. If not, you could write one yourself using some other startup file as template. To schedule the file for being run during startup, use the following command:
chkconfig --level 345 <your file name> on
whereas <your file name>
is relative to /etc/init.d/
.
Please note that you should specify sudo
with its full path (eg. /usr/bin/sudo
) to prevent the possibility of executing another version of sudo
placed somewhere in the search path and you should resolve the .
in ./opt/...
(if executed from the root directory, it would be /opt/...
).
gavss
Updated on September 18, 2022Comments
-
gavss over 1 year
Linux version on the server is Centos 7.0.
Teamspeak server runs with this command:
./opt/teamspeak3-server_linux-x86/ts3server_startscript.sh start
My server doesn't have 100% uptime. Therefore, I want the server program to start automatically using a non root user.