PDA

View Full Version : crontab


Rheno
01-05-2005, 07:34
Anyone use cron for their TS2?

What's a good setup?

Kess
06-05-2005, 17:25
Why do you want to use cron ???

I use cron only for checking if TS is really running.
I wrote a script that checks if the process is up and running and also checks the .pid file.

I cant see no other reason to use the cron daemon.

Rheno
07-05-2005, 02:50
I guess i'd like to do the same thing.

Will the daemon start the service if it has been taken offline?

Can you post a copy of what your crontab looks like for this, it's been about 6 years since i've run a linux server.

curvers
22-05-2005, 10:04
This script checkes teamspeak every minut. You could alter it and use it for other services as well. Dont forget the change the paths

#CRONJOB:
*/5 * * * * server /mnt/shared/linux/scripts/teamspeakcheck.sh

#teamspeakcheck.sh BASH SCRIPT:

pid=`pidof -s /usr/local/teamspeak/server_linux`
if [ $pid ]
then
echo "online"
else
echo "offline"
cd /usr/local/teamspeak/
./server_linux -PID=tsserver2.pid
echo Teamspeak crashed please investigate | mail support@gameserverhost.nl -s Teamspeak crashed at `date '+%d-%m-%Y'`
fi


Alex Curvers
GameServerHost (http://www.gameserverhost.nl)
Crew Leader

linuxoverwindows
30-05-2005, 20:10
i use crontab to run the server startscript checking status. if the status says it seems to be running, the script exits. if the output is anything else, then the start command is issued to the startscript. upon booting, the server checks for the pid file (in the case of a server crash (power failure, etc)) and if it is there it is removed. then the script starts the server within the first minute.

i just run a small server for a couple of games i play, but my buddies use it while im not playing so i like to keep it up and running for them when im not there. the scripts i use seem to be fine, the startup script i had to add because of a power outage knocking the server offline for several hours. linux was up, all other services were up but ts kept thinking it was still running.

also, run ts as an unpriveledged user so if it gets compromised, there is no permissions for said user to do any damage to the system.

--crontab--
* * * * * /home/ts/tss2_rc2/cronscript

--cronscript--
#!/bin/sh
cd /home/ts/tss2_rc2/
if /home/ts/tss2_rc2/teamspeak2-server_startscript status == "the server seems to be running" > /dev/null
then
exit
else
/home/ts/tss2_rc2/teamspeak2-server_startscript start
fi

--startup line (mine is in /etc/rc.local)--
if [ -f /home/ts/tss2_rc2/tsserver2.pid ]
then
echo "removing /home/ts/tss2_rc2/tsserver2.pid"
rm -f /home/ts/tss2_rc2/tsserver2.pid
fi