I've been scratching my head on this for a while. I have a script that is run by a root cron job. The script executes, but there is a script inside the script that wont execute. Here is what we will call scriptA
#!/bin/bash
lines=`wc -l < /var/www/log/addme`;
DATE=`date +%Y-%m-%d`
if [[ $lines > 4 ]];
then
echo " " > /var/www/log/addme
RESTART=/var/www/log/restart.sh
$RESTART
else
echo "No new hosts added" | wall
fi
Basically what the restart.sh script does is to restart a service. Everything works just fine when I run them from terminal, but not as cron jobs... I also tried to just put
./restart.sh
/var/www/log/restart.sh
But with same result. Any thoughts?
$RESTARTto$RESTART >/var/tmp/foo.log 2>&1)?/var/www/log/restart.sh? Is it executable? If not, you canchmod +xit, or run it withbash $RESTARTin your scriptA.MAILTOvariable inside your crontab, so that you can see what errors are generated by the job.[[ $lines > 4 ]]is doing a lexical comparison, which would bring problems with $lines >= 10. You may replace the '>' with '-gt'