minor error in "stderr & stdout" web site FAQ

Mike Fleetwood mike at rockover.demon.co.uk
Sun May 12 08:32:02 EST 2002


Hello,

There appears to be an error in the stderr redirection of the crontab
rsync entry.  In Bourne shell and compatibles (crontab entries are run by
the Bourne shell) redirections are processed from left to right and "2>&1"  
redirects the stderr to the same location stdout is currently directed and 
not to stdout.  Hence:
    cmd 2>&1 > log
directs stderr to the terminal and stdout to the file log.  But:
    cmd > log 2>&1
directs stdout to log and stderr to the same location stdout is current 
redirected, the log file.

Here is a suggested patch for the FAQ on the web site at 
http://samba.anu.edu.au/rsync/FAQ.html
--- rsync.faq.orig      Sun May 12 16:04:12 2002
+++ rsync.faq   Sun May 12 16:11:25 2002
@@ -17,10 +17,11 @@
 they appear on stderr at the local computer. rsync can't intercept them.

 If you have a problem with scripts or cron jobs that produce stderr then 
I
-suggest you use your shell to redirect stderr to stdout. For example you
+suggest you use your shell to redirect stderr and stdout. For example you
 could do a cron line like this:

-0 0 * * * /usr/local/bin/rsync -avz /foobar /foo 2>&1 > logfile
+0 0 * * * /usr/local/bin/rsync -avz /foobar /foo > logfile 2>&1

-this would send both stderr and stdout to "logfile". The magic
-bit is the "2>&1" which says to redirect stderr to stdout.
+this would send both stderr and stdout to "logfile". The magic bit is the
+"2>&1" which says to redirect stderr to to the same descriptor to which
+stdout is currently directed.

All the best,
Mike
-- 
 __  __ _ _     ___    ____ _    ___  ___  _           ___  ___    _
|  \/  (_| | _ / _ \  | ___| |  / _ \/ _ \| |_ _  _  _/   \/   \ _| |
| |\/| | | |/ |  ___| | _| | |_|  __|  ___| __| \/ \/|  O |  O  / _ |
|_|  |_|_|_|\_\\___|  |_|  |____\___|\___||____\_/^\_/\___/\___/\___|





More information about the rsync mailing list