Skip to content

Instantly share code, notes, and snippets.

@benbuckman
Created July 29, 2013 06:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benbuckman/6102425 to your computer and use it in GitHub Desktop.
Save benbuckman/6102425 to your computer and use it in GitHub Desktop.
tee stdout to log inside bash script
#! /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