0

I have this teamspeak server that has a bad habit of crashing sometimes. Therefore I would like to run a script every 5 minute so the server can restart even if I'm not home. I got this script, and it's executable (chmod +x), but it doesn't seem to be running, I added some echos to confirm if it runs and if it fail or succeed, but I get no response, I can't get anything from the log either. ( /var/log/cron )

#!/bin/sh

VALID_CHECK="Server seems to have died"
RESULT=`/home/zuusu/teamspeak3-server_linux-x86/ts3server_startscript.sh status`
TEST_CHECK="Server is running"


/bin/echo "Initiating Server Check"

if [ "$RESULT" == "$TEST_CHECK" ]; then
/home/zuusu/teamspeak3-server_linux-x86/ts3server_startscript.sh status
/bin/echo "Server Restarted"
else
/bin/echo "Server Check Done"
fi

Here is the line from crontab:

*/5 * * * * /home/zuusu/teamspeak3-server_linux-x86/server_check.sh

I used readlink to get the full path.

[root@forum teamspeak3-server_linux-x86]# readlink -f server_check.sh
/home/zuusu/teamspeak3-server_linux-x86/server_check.sh

As you probably notice I'm pretty novice in linux, but I have some experience with programming.

Does this look fine to you guys? Why isn't it working?

  • I have little experience with shell scripts, but the one thing I do know, is that the very first line is very important. It must point to the right path or the script will just die. Also, see if you can run the script itself from a terminal and see what the script itself says. – LPChip Feb 10 '15 at 21:01
  • Who's crontab is that? It is root's or zuusu's? – glenn jackman Feb 10 '15 at 21:04
  • The script runs by itself. It's root's crontab, I couldn't edit it as zuusu. – ninjaPanda Feb 10 '15 at 21:07
-1

I think if you run crontab -e as zuusu and add your cron job line in there it should work.

|improve this answer|||||
  • Ok, I was gonna try that, but I'm probably doing something wrong, cause I get permission denied. I usally run "nano /etc/crontab" adding -e didnt help. Is there another way to start crontab? EDIT: Nevermind that, I used "crontab -e" only and got into some editor, managed to write the command and got the response it installed the new crontab. Just have to wait 2 min and see now. – ninjaPanda Feb 10 '15 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.