Here’s a little snippet to show how to use logger (included with OS/X, don’t know on other platforms) to syslog errors from a bash script. This is probably most useful for a daemonized process, but would work in any script.
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash function debug_log () { logger -t $0 -i -s -- $USER : $BASH_COMMAND } trap debug_log DEBUG echo "This is a trap" echo "This is another trap" exit |
No Comments so far ↓
There are no comments yet...Kick things off by filling out the form below.