kernel-panic
asked on
Shell/Cron/Htdig Problems
MacOS X 10.3.5 | Ht://Dig 3.1.6
When I execute the following command as root, everything works great.
$ sh /Library/Tenon/Htdig/bin/r undig-real tree.sh
When the system crontab executes the same command, I get errors:
htdig: Unable to open/create document database '/Library/Tenon/Htdig/db/www.realtree.com/db.docdb.work'
htmerge: Unable to create temporary word file '/Library/Tenon/Htdig/db/www.realtree.com/db.wordlist.work.new'
Here's the crontab:
0 2 * * * root sh /Library/Tenon/Htdig/bin/r undig-real tree.sh
Here are the contents of the shell script:
#! /bin/sh
if [ "$1" = "-v" ]; then
verbose="-v"
fi
# This is the directory where htdig lives
BASEDIR=/Library/Tenon/Htd ig
# This is the db dir
DBDIR=$BASEDIR/db/www.realtree.com
# This is the directory htdig will use for temporary sort files
TMPDIR=/tmp
export TMPDIR
# This is the name of a temporary report file
REPORT=$TMPDIR/htdig.realt ree
# This is who gets the report
REPORT_DEST="webmaster@gra yloon.com"
export REPORT_DEST
# This is the subject line of the report
SUBJECT="ht://Dig Report for Realtree"
# This is the name of the conf file to use
CONF=www.realtree.com.conf
# This is the PATH used by this script. Change it if you have problems
# with not finding wc or grep.
PATH=/usr/local/bin:/usr/b in:/bin
##### Dig phase
STARTTIME=`date`
echo Start time: $STARTTIME
echo rundig: Start time: $STARTTIME > $REPORT
$BASEDIR/bin/htdig $verbose -s -a -c $BASEDIR/conf/$CONF >> $REPORT
TIME=`date`
echo Done Digging: $TIME
echo rundig: Done Digging: $TIME >> $REPORT
##### Merge Phase
$BASEDIR/bin/htmerge $verbose -s -a -c $BASEDIR/conf/$CONF >> $REPORT
TIME=`date`
echo Done Merging: $TIME
echo rundig: Done Merging: $TIME >> $REPORT
##### Cleanup Phase
# To enable htnotify, uncomment the following line
# $BASEDIR/bin/htnotify $verbose >>$REPORT
# To enable the soundex or endings search, uncomment the following line
$BASEDIR/bin/htfuzzy $verbose -c $BASEDIR/conf/$CONF endings
# Move the work files
mv $DBDIR/db.wordlist.work $DBDIR/db.wordlist
mv $DBDIR/db.docdb.work $DBDIR/db.docdb
mv $DBDIR/db.docs.index.work $DBDIR/db.docs.index
mv $DBDIR/db.words.db.work $DBDIR/db.words.db
END=`date`
echo End time: $END
echo rundig: End time: $END >> $REPORT
echo
# Grab the important statistics from the report file
# All lines begin with htdig: or htmerge: or rundig:
fgrep "htdig:" $REPORT
echo
fgrep "htmerge:" $REPORT
echo
fgrep "rundig:" $REPORT
echo
WC=`wc -l $REPORT`
echo Total lines in $REPORT: $WC
# Send out the report ...
mail -s "$SUBJECT - $STARTTIME" $REPORT_DEST < $REPORT
# ... and clean up
rm $REPORT
When I execute the following command as root, everything works great.
$ sh /Library/Tenon/Htdig/bin/r
When the system crontab executes the same command, I get errors:
htdig: Unable to open/create document database '/Library/Tenon/Htdig/db/www.realtree.com/db.docdb.work'
htmerge: Unable to create temporary word file '/Library/Tenon/Htdig/db/www.realtree.com/db.wordlist.work.new'
Here's the crontab:
0 2 * * * root sh /Library/Tenon/Htdig/bin/r
Here are the contents of the shell script:
#! /bin/sh
if [ "$1" = "-v" ]; then
verbose="-v"
fi
# This is the directory where htdig lives
BASEDIR=/Library/Tenon/Htd
# This is the db dir
DBDIR=$BASEDIR/db/www.realtree.com
# This is the directory htdig will use for temporary sort files
TMPDIR=/tmp
export TMPDIR
# This is the name of a temporary report file
REPORT=$TMPDIR/htdig.realt
# This is who gets the report
REPORT_DEST="webmaster@gra
export REPORT_DEST
# This is the subject line of the report
SUBJECT="ht://Dig Report for Realtree"
# This is the name of the conf file to use
CONF=www.realtree.com.conf
# This is the PATH used by this script. Change it if you have problems
# with not finding wc or grep.
PATH=/usr/local/bin:/usr/b
##### Dig phase
STARTTIME=`date`
echo Start time: $STARTTIME
echo rundig: Start time: $STARTTIME > $REPORT
$BASEDIR/bin/htdig $verbose -s -a -c $BASEDIR/conf/$CONF >> $REPORT
TIME=`date`
echo Done Digging: $TIME
echo rundig: Done Digging: $TIME >> $REPORT
##### Merge Phase
$BASEDIR/bin/htmerge $verbose -s -a -c $BASEDIR/conf/$CONF >> $REPORT
TIME=`date`
echo Done Merging: $TIME
echo rundig: Done Merging: $TIME >> $REPORT
##### Cleanup Phase
# To enable htnotify, uncomment the following line
# $BASEDIR/bin/htnotify $verbose >>$REPORT
# To enable the soundex or endings search, uncomment the following line
$BASEDIR/bin/htfuzzy $verbose -c $BASEDIR/conf/$CONF endings
# Move the work files
mv $DBDIR/db.wordlist.work $DBDIR/db.wordlist
mv $DBDIR/db.docdb.work $DBDIR/db.docdb
mv $DBDIR/db.docs.index.work $DBDIR/db.docs.index
mv $DBDIR/db.words.db.work $DBDIR/db.words.db
END=`date`
echo End time: $END
echo rundig: End time: $END >> $REPORT
echo
# Grab the important statistics from the report file
# All lines begin with htdig: or htmerge: or rundig:
fgrep "htdig:" $REPORT
echo
fgrep "htmerge:" $REPORT
echo
fgrep "rundig:" $REPORT
echo
WC=`wc -l $REPORT`
echo Total lines in $REPORT: $WC
# Send out the report ...
mail -s "$SUBJECT - $STARTTIME" $REPORT_DEST < $REPORT
# ... and clean up
rm $REPORT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.