LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-08-2005, 07:27 PM   #1
zend
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Rep: Reputation: 0
Call of Duty 2 Cronjob Not working [SOLVED]


I've started a Call of Duty 2 server. My startup script runs fine if I start it manually.

I have a cronjob that checks to see if the server is running. If it isn't it is supposed to start it. I can't get the cronjob to start the server.

The script is:
#!/bin/sh

if ( ps awwwx | grep 'cod2_lnxded' | grep 'CoD2' ) >>/dev/null
then
echo "Call of Duty 2 server still UP!"
exit 22
fi

start=`date '+%H:%M on %d/%m/%y'`
echo "CoD 2 server started @ $start" >>/usr/local/games/CoD2.log
cd /usr/local/games/cod2
screen -A -m -d -S CoD2 ./cod2_lnxded +set dedicated 2 +exec kgbcod2.cfg +map_rotate


My cronjob is:

*/30 * * * * * /usr/local/games/cod2/zend_cod2.sh

From the cronjob I get the message:

Nov 8 19:29:00 kgbserver fcron[3089]: Job * /usr/local/games/cod2/zend_cod2.sh started for user user1 (pid 3090)
Nov 8 19:29:00 kgbserver fcron[3089]: Job * /usr/local/games/cod2/zend_cod2.sh terminated (exit status: 127) (mailing output)


Again. The script runs just fine when I start it manually. What am I doing wrong?

Last edited by zend; 11-15-2005 at 11:03 AM.
 
Old 11-09-2005, 02:23 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,995
Blog Entries: 5

Rep: Reputation: 782Reputation: 782Reputation: 782Reputation: 782Reputation: 782Reputation: 782Reputation: 782
The cron doesn't inherit the same environment as a normal user does on login. The main culprit for things that run at command line but NOT in cron is PATH. Essentially cron doesn't know where commands like "ps", "screen", "date" or others that are not internal to the shell live.


You can resolve this by adding a PATH=path1: path2: path3 statement for the paths where these commands live (i.e. /bin, /usr/bin, /usr/local/bin) Note I put spaces in to prevent smileys - you wouldn't have spaces between the : and the next element of path.

OR just define full path for each as variables and call the variables - example:

#!/bin/sh

PS=/bin/ps
SCREEN=/usr/bin/screen
DATE=/bin/date
GREP=/bin/grep

if ( $PS awwwx | $GREP 'cod2_lnxded' | $GREP 'CoD2' ) >>/dev/null
then
echo "Call of Duty 2 server still UP!"
exit 22
fi

start=`$DATE '+%H:%M on %d/%m/%y'`
echo "CoD 2 server started @ $start" >>/usr/local/games/CoD2.log
cd /usr/local/games/cod2
$SCREEN -A -m -d -S CoD2 ./cod2_lnxded +set dedicated 2 +exec kgbcod2.cfg +map_rotate

You don't need echo, if, then, exit, fi or cd defined as they are internal to the shell.

Last edited by MensaWater; 11-09-2005 at 02:24 PM.
 
Old 11-14-2005, 11:33 PM   #3
zend
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks for the suggestion, but I have the same problem as before.

Last edited by zend; 11-15-2005 at 09:24 AM.
 
Old 11-15-2005, 10:52 AM   #4
zend
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Original Poster
Rep: Reputation: 0
I just figured out that I had one too many * in my crontab line. Now it's working.

Last edited by zend; 11-15-2005 at 10:59 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TeamSpeak2 and Call of Duty mikedeatworld Linux - Software 3 02-11-2005 08:39 PM
Call of Duty doesn't run SiW Linux - Software 0 02-11-2005 04:04 AM
Help with Call of duty CoDGangster Linux - Games 1 12-09-2004 07:58 PM
Call of Duty. TuxToaster Linux - Games 42 11-27-2004 06:47 AM
call of duty g33k Linux - Games 6 02-03-2004 01:04 AM


All times are GMT -5. The time now is 11:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration