Skip to content

Instantly share code, notes, and snippets.

@scalp42
Forked from solidsnack/logtee.bash
Created December 28, 2015 23:17
Show Gist options
  • Save scalp42/d6af1ce5413cebcf4b52 to your computer and use it in GitHub Desktop.
Save scalp42/d6af1ce5413cebcf4b52 to your computer and use it in GitHub Desktop.
Log STDOUT and STDERR to both syslog and the console.
#!/bin/bash
set -o errexit -o pipefail -o nounset
# Log STDOUT and STDERR to both syslog and the console.
exec 3>&1
exec 4>&2
exec 1> >(tee >(logger -p user.info) 1>&3)
exec 2> >(tee >(logger -p user.notice) 2>&4)
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment