Created
July 29, 2013 06:10
-
-
Save benbuckman/6102425 to your computer and use it in GitHub Desktop.
tee stdout to log inside bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# concept from http://stackoverflow.com/a/3403786/267224 | |
############# | |
# log to file | |
LOGFILE=/home/user/log/script.log | |
exec > >(tee -a $LOGFILE) | |
exec 2>&1 | |
############ | |
# anything that outputs to stdout or stderr... | |
# don't need to pipe or tee the script itself, just run it and it pipes internally. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment