I am running a bash script that creates a log file for the execution of the command
I use the following
Command1 >> log_file
Command2 >> log_fileThis only sends the standard output and not the standard error which appears on the terminal.
05 Answers
If you want to log to the same file:
command1 >> log_file 2>&1If you want different files:
command1 >> log_file 2>> err_file 12 The simplest syntax to redirect both is:
command &> logfileIf you want to append to the file instead of overwrite:
command &>> logfile 9 You can do it like that 2>&1:
command > file 2>&1 3 Use:
command >>log_file 2>>log_file Please use command 2>fileHere 2 stands for file descriptor of stderr. You can also use 1 instead of 2 so that stdout gets redirected to the 'file'