> -----Original Message----- > From: Daniel Tan [mailto:danieltan@;shopnsave.com.sg] > Sent: Friday, October 18, 2002 9:39 PM > To: Redhat 2 > Subject: Backup script creating 2 mails > > > Hi all, > i have a backup script that will send me an email > after backup has finished. But i keep receiving 2 mails > instead of 1. The additional email contains these..how do > i prevent that mail from appearing? > > Subject: Cron <root@mail> /root/bakupdaily > Body: tar: Removing leading `/' from member names > > My Backup Script: > #!/bin/sh > echo Backup started at `date` > bakupweekly.log > tar -cvf /dev/st0 /var/spool/mail /var/spool/mqueue /var/www > /etc /var/named /home /boot /root >> bakupweekly.log > echo Backup stopped at `date` >> bakupweekly.log > mail -s "Backup Weekly Log" "admin@mail" < bakupweekly.log >
Based on your post, I think the reason you are receiving two e-mails is -- In your backup script, you are redirecting stdout to the file bakupweekly.log, but you are NOT redirecting stderr to the same file. So stderr is being sent to root@mail because its part of the cronjob output, but stdout is being redirected to your backup file and then mailed to another account. In other words, your tar syntax is causing tar to output to both stdout and stderr. To fix, choose one of the following options: 1) fix your tar syntax so that it does not generate stderr output. 2) Add the MAILTO variable to your backup script and then remove all redirects along with your 'mail' command. It's no longer needed. Ex: #!/bin/sh MAILTO=admin@mail echo Backup started at `date` etc... etc... 3) Change each line in your shell script that redirects output to include stderr... EX: echo Backup started at `date` >bakupweekly.log 2>&1 Steve Cowles -- redhat-list mailing list unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list