Technical question regarding Cron jobs
#1
So we run a Teamspeak2 server here at the Lounge. Works great. But when Something Goes Wrong™ and the server gets bounced, or there's maintenance, whatever, the Teamspeak2 server goes down.

In order for it to come back up, the file tsserver2.pid needs to be deleted in the tss2_rc2 directory and the teamspeak2-server_startscript file executed. I can do this manually, no problem.

I've set up a cron job, however, that should do this automatically, and run every 15 minutes. It checks to see if a Teamspeak2 process is running, and if not, delete the tsserver2.pid file and restart Teamspeak2.

The cron job runs this file:

Code:
#!/bin/sh
#
# TeamSpeak Cron Job
# Author: Chris Childers
# E-Mail: Chris@darkstarllc.com
# Address: http://www.darkstarllc.com
#

### Set your default TS Root Directory
tsdir="/tss2_rc2"

### Set your TS Binary Name
tsbin="server_linux"

### Set your TS Pid File
tspid="tsserver2.pid"

########## you probably don't need to change anything below here ##########

cd $tsdir

# is there a pid file?
if test -r $tspid
then
  # there is a pid file -- is it current?
  pid=`cat $tspid`
  if `kill -CHLD $pid >/dev/null 2>&1`
  then
    echo "TeamSpeak is currently running...."
    exit 0
  fi
  echo ""
  echo "Stale $tspid file, erasing..."
  echo "Attempting to Restart TeamSpeak"
  rm -f $tspid
  ./$tsbin -PID=$tspid &
else
echo "$tspid appears to be missing. Attempting to Restart TeamSpeak"
./$tsbin -PID=$tspid
fi

If I execute this manually, I receive:

Code:
: bad interpreter: No such file or directory

Thing is, if I go to /bin, sh is right there and can be run as an interpreter just fine. So can bash. But if the file being executed by the cron job goes to run it, I get that error.

Yes, I'm a linux newb. WTF is wrong here?

-Bolty
Quote:Considering the mods here are generally liberals who seem to have a soft spot for fascism and white supremacy (despite them saying otherwise), me being perma-banned at some point is probably not out of the question.
Reply


Messages In This Thread
Technical question regarding Cron jobs - by Bolty - 08-22-2006, 04:57 AM
Technical question regarding Cron jobs - by Wyrm - 08-22-2006, 07:27 AM
Technical question regarding Cron jobs - by Bolty - 08-22-2006, 11:35 AM
Technical question regarding Cron jobs - by Bolty - 08-22-2006, 01:31 PM
Technical question regarding Cron jobs - by Doc - 08-22-2006, 02:58 PM
Technical question regarding Cron jobs - by Yrrek - 08-23-2006, 03:35 AM

Forum Jump:


Users browsing this thread: 7 Guest(s)