Subjectively

dd if=/dev/random | kirk > blog

Subjectively header image 2

Writing to syslog in a bash script

November 30th, 2009 · No Comments · OS X

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

Tags:

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

You must log in to post a comment.