Created
November 26, 2015 11:15
-
-
Save nuada/e3b6278df68c8d081d59 to your computer and use it in GitHub Desktop.
BASH script that automatically logs strerr and stdout to given file.
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 | |
| LOG=/path/to/log_file.log | |
| >${LOG} | |
| exec > >(tee -a ${LOG}) | |
| trap "kill -9 $! 2>/dev/null" EXIT | |
| exec 2> >(tee -a ${LOG} >&2) | |
| trap "kill -9 $! 2>/dev/null" EXIT | |
| echo Test 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment