Results 1 to 8 of 8
-
04-05-2011, 01:22 #1
-= TeamSpeak User =-
- Join Date
- May 2011
- Posts
- 5
Very simple server auto start method and crash restart script (root & non-root)
Here is a simple script I wrote to automatically start a TS3 server on boot and auto restart after a crash. Tested with CentOS 5.x and Ubuntu 10 & 11, but should work with most distros.
For x86:
For x64:Code:#!/bin/bash TEAMSPEAK=`ps ax | grep ts3server_linux_x86 | grep -v grep | wc -l` if [ $TEAMSPEAK -eq 1 ] then exit else cd /path/to/teamspeak ; ./ts3server_startscript.sh start fi
Change "/path/to/teamspeak" to your actual TeamSpeak directory.Code:#!/bin/bash TEAMSPEAK=`ps ax | grep ts3server_linux_amd64 | grep -v grep | wc -l` if [ $TEAMSPEAK -eq 1 ] then exit else cd /path/to/teamspeak ; ./ts3server_startscript.sh start fi
Script is also included as an attachment at the bottom, simply put it in a directory on your server (such as the teamspeak directory).
Login as the user you wish to run this as, this does not have to be root. In crontab add a line such as this:
Where */2 is 2 minutes, change to */5 for 5 minutes.. and so on. This is after how many minutes to check if the server is running, and if not to attempt to start it.Code:*/2 * * * * sh /path/to/script/script.sh
This works best when you have an additional line in crontab like:
Again changing the path. This will start the server automatically after boot (otherwise you would have to wait for the script to run after boot). TeamSpeak server will then run as the same user who added the crontab entries.Code:@reboot cd /path/to/teamspeak ; ./ts3server_startscript.sh start
A thing to note, you may have to comment the script line in crontab with # when updating the TeamSpeak server so it doesn't automatically start it. Then uncomment it again after. There is also a limitation, if the server won't start due to error it will keep attempting to start it.
Disclaimer: Though this script was created by me, I accept no responsibility for data loss or damage by the use of the script though it should be perfectly safe to use.
Attached file is for x86 server version, for x64 change line 3 from "ts3server_linux_x86" to "ts3server_linux_amd64".Last edited by Arandas; 04-05-2011 at 01:40.
-
30-05-2011, 16:35 #2
-= TeamSpeak User =-
- Join Date
- Jan 2010
- Location
- The US
- Posts
- 10
I know, I'm practicing thread necromancy, since no one has posted to this thread in more than 2 months, but I just wanted to tell the OP Thank you. Thanks a ton. You solved a problem that stopped me from trying to run my own TS3 server 2 years ago. and you explained it nicely with an attached cron job I was actually able to use as well. Thank you so very much. Someone sticky this please.
-
12-11-2011, 14:44 #3
-= TeamSpeak User =-
- Join Date
- Jul 2011
- Location
- Scotland
- Posts
- 2
Perfect simple auto start script
This is perfect, well explained and very easy to implement. Thanks for the file too.
I have been looking for months for this. Thank you so much.
I agree this definately deserves a sticky.
-
11-07-2012, 20:34 #4
-= TeamSpeak User =-
- Join Date
- Jan 2012
- Posts
- 9
This looks like exactly what im looking for but im running in to an issue, if i had my script.sh stored in my Teamspeak Directory at /home/teamspeakserver would the path to teamspeak be /home/teamspeakserver/teamspeak3-server_linux-x86 or just /teamspeak3-server_linux-x86 ?
-
11-07-2012, 20:59 #5
-= TeamSpeak Fanatic =-
- Join Date
- Jan 2010
- Location
- Germany
- Posts
- 2,039
Nope needs to be the full path.
-
15-07-2012, 11:02 #6
-= TeamSpeak User =-
- Join Date
- Jun 2012
- Location
- Poland
- Posts
- 14
Thanks Arandas this is 100% working
for boot system, and when TeamSpeak is stopped just worked.
I recommend!Last edited by LS_ARRoW; 15-07-2012 at 11:22.
-
16-07-2012, 07:13 #7
-= TeamSpeak Addict =-
- Join Date
- Jun 2011
- Location
- Russian Federation
- Posts
- 208
how do I:
crontab:Code:#!/bin/bash TEAMSPEAK=`ps ax | grep ts3server_linux_x86 | grep -v grep | wc -l` if [ $TEAMSPEAK -eq 1 ] then exit else cd /home/archi/teamspeak3-server_linux-x86 ; ./ts3server_startscript.sh start
as a result of the logs, I:Code:*/2 * * * * cd ~/scripts && sh crash.sh
after commenting in the crontab "#" of a script error no!Code:Jul 16 10:08:01 ts3 /USR/SBIN/CRON[5721]: (CRON) error (grandchild #5725 failed with exit status 1) Jul 16 10:08:01 ts3 /USR/SBIN/CRON[5721]: (CRON) info (No MTA installed, discarding output)
Question! what's the problem?
-
24-07-2012, 03:25 #8
-= TeamSpeak User =-
- Join Date
- Jun 2009
- Location
- Australia
- Posts
- 11
AFAIK another script isn't necessary and you can just cron the start script itself?
Please correct me if I am wrong.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
HOWTO: modified start script for auto starting on server boot (ts3 as non-root user)
By fratzi in forum Linux / FreeBSDReplies: 1Last Post: 07-04-2010, 14:34 -
Auto start without root privileges
By chx86 in forum [TeamSpeak 2] Server SupportReplies: 2Last Post: 15-07-2007, 10:22 -
Auf den Root laufenden server mit dem root draufconnecten?
By XpLoDeR24 in forum [TeamSpeak 2] Server SupportReplies: 10Last Post: 20-05-2006, 11:20 -
Err with start under not root user
By Sandr in forum [TeamSpeak 2] Server SupportReplies: 1Last Post: 13-02-2005, 03:48 -
Startup script NOT AS ROOT
By Heavenstrash in forum [TeamSpeak 2] Server SupportReplies: 10Last Post: 05-07-2003, 05:45


Reply With Quote