Skip to main content
added 23 characters in body; edited title
Source Link
peterh
  • 10.5k
  • 18
  • 70
  • 99

How to copy standard output and standard error to the log?

I need to write the standard err and standard output to $LOG$LOG, while also having them printed on console, from within a script.

The script has many commands, so redirecting each one of them is not a good solution.

I've tried this, but it didn't work as expected:

#!/bin/bash

LOG=/var/tmp/log

#...

exec > $LOG  2>&1

My target is to write to $LOG$LOG on any standard output and standard errerror, but on the same time also to the standard output (on console). Is it possible?

How to copy standard output and standard error to log

I need to write standard err and standard output to $LOG while also having them printed on console, from within a script.

The script has many commands so redirecting each one of them is not a good solution.

I've tried this but it didn't work as expected:

#!/bin/bash

LOG=/var/tmp/log

#...

exec > $LOG  2>&1

My target is to write to $LOG on any standard output and standard err but on the same time to standard output (on console). Is it possible?

How to copy standard output and standard error to the log?

I need to write the standard err and standard output to $LOG, while also having them printed on console, from within a script.

The script has many commands, so redirecting each one of them is not a good solution.

I've tried this, but it didn't work as expected:

#!/bin/bash

LOG=/var/tmp/log

#...

exec > $LOG  2>&1

My target is to write to $LOG on any standard output and standard error, but on the same time also to the standard output (on console). Is it possible?

Clarified question title and text based on author comments
Source Link

How to writecopy standard output and standard error to log and from exec

For example,I need to write standard err and standard output to $LOG. but this not print anything to standard output ( while also having them printed on console ), from within a script.

The script has many commands so redirecting each one of them is not a good solution.

I've tried this but it didn't work as expected:

#!/bin/bash

LOG=/var/tmp/log

#...

exec > $LOG  2>&1

myMy target is to write to $LOG on any standard output and standard err but on the same time to standard output ( onon console  ). Is it possible?

How to write standard output and error to log and from exec

For example, write standard err and standard output to $LOG. but this not print anything to standard output ( on console )

#!/bin/bash

LOG=/var/tmp/log

#...

exec > $LOG  2>&1

my target is to write to $LOG on any standard output and standard err but on the same time to standard output ( on console  ). Is it possible?

How to copy standard output and standard error to log

I need to write standard err and standard output to $LOG while also having them printed on console, from within a script.

The script has many commands so redirecting each one of them is not a good solution.

I've tried this but it didn't work as expected:

#!/bin/bash

LOG=/var/tmp/log

#...

exec > $LOG  2>&1

My target is to write to $LOG on any standard output and standard err but on the same time to standard output (on console). Is it possible?

how How to write standard output and error to log and from exec

thisFor example  , write standard err and standard output to $LOG. but this not print anything to standard output ( on console )

#!/bin/bash
 

LOG=/var/tmp/log
 

.
#.
 .
 .
 

exec > $LOG  2>&1

my target is to write to $LOG on any standard output and standard err but on the same time to standard output ( on console )

is. Is it possible?

how to write standard output and error to log and from exec

this example  , write standard err and standard output to $LOG but this not print anything to standard output ( on console )

#!/bin/bash
 

LOG=/var/tmp/log
 

.
.
 .
 .
 

exec > $LOG  2>&1

my target is to write to $LOG on any standard output and standard err but on the same time to standard output ( on console )

is it possible?

How to write standard output and error to log and from exec

For example, write standard err and standard output to $LOG. but this not print anything to standard output ( on console )

#!/bin/bash

LOG=/var/tmp/log

#...

exec > $LOG  2>&1

my target is to write to $LOG on any standard output and standard err but on the same time to standard output ( on console ). Is it possible?

edited tags
Link
terdon
  • 252.7k
  • 69
  • 481
  • 719
Loading
Source Link
yael
  • 14k
  • 72
  • 221
  • 377
Loading