The code below should redirect all output to /dev/null however root still receives an email with output from the first command (/usr/bin/svnadmin). Why?
#!/bin/sh
# Dump repo and upload via tarsnap
/usr/bin/svnadmin dump /srv/repos/www | gzip > /srv/repos/backup/www-repo-`date --iso-8601`.gz > /dev/null 2>&1
/usr/local/bin/tarsnap -c -f www-repo-`date --iso-8601` /srv/repos/backup/www-repo-`date --iso-8601`.gz > /dev/null 2>&1
Answer
You have piped the second commands STDOUT and STDERR to /dev/null, and only piped the first command's STDOUT to the second command. So the first command's STDERR is e-mail-ed to you.
You should write
( /usr/bin/svnadmin dump /srv/repos/www | gzip > /srv/repos/backup/www-repo-`date --iso-8601`.gz ) > /dev/null 2>&1
No comments:
Post a Comment