Skip to content

Instantly share code, notes, and snippets.

@solidsnack
Created June 9, 2015 22:52
Show Gist options
  • Save solidsnack/19ee544048fa59798f25 to your computer and use it in GitHub Desktop.
Save solidsnack/19ee544048fa59798f25 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