Created
May 1, 2013 01:25
-
-
Save mdub/5493185 to your computer and use it in GitHub Desktop.
Redirect STDOUT and STDERR into syslog, using "logger", and bash process substitution
This file contains 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
# Redirect STDOUT/STDERR into syslog | |
exec > >(logger -p user.info) 2> >(logger -p user.warn) |
@shribe Thank you! Exactly what I needed.
If you add another "exec " in front of the logger call, you avoid one additional Bash process staying alive all the time (you can see it with pstree). Like this:
exec > >(exec logger -p user.info) 2> >(logger -p user.warn)
@mpdude: the entire concept only works with bash (not with sh), since it uses "Process Substitution" which is a Bash-only feature.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is that for bash only or does it work in sh as well?