-
-
Save motionbug/29cf7edff9a9ba51724dc6079f74fbfa to your computer and use it in GitHub Desktop.
tee stdout to log inside bash script
This file contains 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