Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

2 Answers 2

up vote 1 down vote accepted

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
share|improve this answer

With my reputation I can't add comments, so I'll have to submit an answer allthough I'm not sure this is the case.

What does your crontab look like? I don't think it's your script that sends the e-mail, cron/crontab is doing that. So please show us contents of your crontab (crontab -e).

I might be wrong (I actually used cron myself for the first time just yesterday), but I think you should have the > /dev/null 2>&1 part in your crontab rather than in your script file. So your crontab could look something like this:

@hourly /your/script/location > /dev/null 2>&1

Hope this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.