Created
November 14, 2017 22:20
-
-
Save andrewjong/6368d11c8bf88f59e467c4b42e2248fb to your computer and use it in GitHub Desktop.
Log output to file bash
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
# Logs stdout and stderr | |
logFile='ask_reboot_log.txt' | |
exec > >(tee -ia $logFile) | |
exec 2> >(tee -ia $logFile >&2) | |
echo 'Hello' | |
echo 'error output' >&2 | |
# https://stackoverflow.com/questions/3173131/redirect-copy-of-stdout-to-log-file-from-within-bash-script-itself |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment