Server TeaSpeak AutoStart Script(also AutoStart after Crash)

farhadhelix

Fanatic member
Premium User
Hello
this is a little script that will make your TeaSpeak server to autostart itself on startup and on server crashes
with this tutorial you can assure your Teaspeak server is always running even after crashes

first go to your /home

Code:
 cd /home
then make a file named tsanticrash.sh

Code:
 nano tsanticrash.sh
then an empty screen will be opened .then paste the codes below into it(simply copy code here and paste them into that empty screen by just RIGHT CLICK on putty )

Code:
#!/bin/bash
case $1 in
teaspeakserver)
teaspeakserverpid=`ps ax | grep TeaSpeakServer | grep -v grep | wc -l`
if [ $teaspeakserverpid -eq 1 ]
then exit
else cd /home/teaspeak/
./teastart.sh start
fi
;;
esac

Important Note : change the "/home/teaspeak/" to the exact installation folder
then pres combinations of these two buttons on your keyboard (CTRL+X) then Press type y and then press ENTER to save and exit

then run this command below to grant permission to the file you just created

Code:
 chmod 777 tsanticrash.sh
then you have to create a cronjob for this script to check it every 1 minutes

Code:
 crontab -e
you will then enter into your system cronjobs area

go the the last line of it and enter code below(simply copy code here and paste them into that empty screen by just RIGHT CLICK on putty )


Code:
 */1 * * * * /home/tsanticrash.sh teaspeakserver
then again (CTRL+X) then Press type y and then press ENTER to save and exit

your all done. every 1 minute it will check if there is teaspeakserver running or not and if there is no server it will start it itself
 
Last edited:

Ashka

New member
Premium User
What happens to the script if I stop the server to work, do I have to delete the script?
 

farhadhelix

Fanatic member
Premium User
What happens to the script if I stop the server to work, do I have to delete the script?
just enter your crontab with typing "crontab -e"
find that code (*/1 * * * * /home/tsanticrash.sh teaspeakserver)
and simply put an # in the begining of it

#*/1 * * * * /home/tsanticrash.sh teaspeakserver

then save and quit crontab