Skip to content

Instantly share code, notes, and snippets.

@andrewjong
Created November 14, 2017 22:20
Show Gist options
  • Save andrewjong/6368d11c8bf88f59e467c4b42e2248fb to your computer and use it in GitHub Desktop.
Save andrewjong/6368d11c8bf88f59e467c4b42e2248fb to your computer and use it in GitHub Desktop.
Log output to file bash
# 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