This question is related to Gentoo Linux.
I have cron job that runs every morning at 10AM. The cron job calls a bash script which in turn calls a groovy script that queries the database for a column of data and emails the result to a recipient list.
Every day the script executes, it sends out the exact same data. When I run the script manually it, reports (and emails) the correct data. I'm at a complete loss of how to further troubleshoot this. What gives?
Here's my cronjob script:
#!/bin/bash
OUTPUT=""
TEMPFILE=/tmp/dsr.output
MAILTO="[email protected]"
INSTALL_DIR=/usr/local/clearleap/scripts/daily-storage-report
export CLASSPATH=$CLASSPATH:$INSTALL_DIR/lib/postgresql-8.3-603.jdbc4.jar:$INSTALL_DIR
OUTPUT=$(/opt/groovy/bin/groovy $INSTALL_DIR/DailyStorageReport.groovy)
echo "$OUTPUT" > $TEMPFILE
echo $OUTPUT
echo $OUTPUT | /bin/mailx -s "Daily Storage Report" $MAILTO
Here is the cronjob itself, which lives in /etc/cron.d/dsr_cron:
0 10 * * * root /usr/local/clearleap/scripts/daily-storage-report/dsr.sh
Please let me know if you'd like to see the code from the groovy script. I have no idea why it appears to be caching!
Any help is greatly appreciated!
/tmp/dsr.output
?TEMPFILE=/tmp/dsr.output
- I strongly suggest you consider using mktemp or something that will create a randomly name temporary file. Imagine what would happen if/tmp/dsr.output
didn't exist and some unprivileged user or serves made/tmp/dsr.output
a symlink to/etc/passwd
? Secure temp file usage - codeproject.com/Articles/15956/…