For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > stderr Redirection

stderr Redirection

Created by dave. Last edited by dave, 2 years and 278 days ago. Viewed 890 times. #2
[diff] [history] [edit] [rdf]

Order Matters In STDERR redirection

So the typical problem is that a cron job is leaking stderr output into mail even though there is a perfectly good looking 2>&1 in the command line.

However, the order you put things on the command line matters.

So this will redirect stderr to stdout and then stdout into a file:

command >> $FILE 2>&1

...but this won't:

command 2>&1 >> $FILE

I was usually using the second format in my crontab entries because it makes logical sense. However it doesn't do what you expect it to do.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt