Redirect all shell output to a single file
From LinuxReviews
Jump to navigationJump to searchShell commands send two kinds of text to terminals: standard output and standard error stdout/stderr).
stdout are captured as 1,
./shellscript 1>>foo
stderr as 2,
./shellscript 2>>foo
If you want to send all output to a log file then use the following:
./shellscript >> /path/to/logfile 2>&1
2>&1 redirects standard error messages to standard out, which allows you to capture both to a single file.
Note that >> opens a file and writes to the end of it, > zeroes the file if it exists and then redirects to it.