PDA

View Full Version : Script does not execute with cron



JBottero
05-17-2008, 02:09 AM
I've created the following shell script to rotate a log file (yes, I know about logrotate)
#!/bin/bash

mv /var/spool/qmailscan/qmail-queue.backup-3.tar.gz /var/spool/qmailscan/qmail-queue.backup-4.tar.gz
mv /var/spool/qmailscan/qmail-queue.backup-2.tar.gz /var/spool/qmailscan/qmail-queue.backup-3.tar.gz
mv /var/spool/qmailscan/qmail-queue.backup-1.tar.gz /var/spool/qmailscan/qmail-queue.backup-2.tar.gz
mv /var/spool/qmailscan/qmail-queue.backup.tar.gz /var/spool/qmailscan/qmail-queue.backup-1.tar.gz

LOGFILE=/var/spool/qmailscan/qmail-queue.log

tar -cvzf /var/spool/qmailscan/qmail-queue.backup.tar.gz $LOGFILE
echo "" > $LOGFILE

And I have this cron job
30 */6 * * * /var/spool/qmailscan/qmail-queue-log-rotate.sh 2> /dev/null This should execute the script 30 minutes past every 6 hours (0030, 0630, 1230, 1830).

But while I can execute the script from the command line, if left to cron nothing seems to happen.

Any ideas?

Also...

When I do execute it from the command line, I get this:
./qmail-queue-rotate.sh
tar: Removing leading `/' from member names
var/spool/qmailscan/qmail-queue.logWhat does "Removing leading `/' from member names" mean?