Let me explain… As a relative command line newbie the characters 2>&1 & at the end of commands are quite intreguing. I figured out what they mean

The command line apps have 3 types of output

  • Standard input (STDIN)
  • Standard output (STDOUT)
  • Error output (STDERR)

So, when you run this command:

[tim@desktop]$ programName > filename.log 2>&1

The output of the program is output into the file and the output from output 2 (STDERR) is sent to output 1 (STDOUT). This effectively sends any errors into the file also.

If you add a space& like so to the end of the command it sends it to the background and returns the pid (in case you need to track/kill it).

[tim@desktop]$ programName > filename.log 2>&1 &

Thanks to: http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/comment-page-3/ for the detail (& Sasha for clarifying some things)