I have a bash script where I use
gnome-terminal -e /folder/script1 &
gnome-terminal -e /folder/script2 &
to open two new terminals and carry out two parallel jobs.
I want to know if it is possible to log the output of these scripts by using something like
gnome-terminal -e /folder/script1 2>&1 | tee script1.log
Thank you.
Try:
gnome-terminal -e 'bash -c "/folder/script1 2>&1 | tee /tmp/script1.log"'
Explanation:
gnome-terminal -e /folder/script1 2>&1
opens a gnome-terminal, executes /folder/script1
, and directs stderr of the gnome-terminal command to stdout. To redirect stderr of script1
to stdout, we need a shell. The same goes for | tee /tmp/script1.log
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With