|
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.
|