How To Log Bash History to Syslog
jablonskis.org
jablonskis.org
I've never used it, but I assume >() uses a command as though it were a writable file. So instead of history -a file writing to file, he does history -a >(logger) to write to the logger command. Seems pretty clever to me.
$ cat writer.sh
#!/bin/bash
if [[ "$#" == 1 ]]; then
echo "Wrote to file named $1" > "$1"
else
echo "Wrote to stdout"
fi
$ ./writer.sh
Wrote to stdout
$ ./writer.sh | cat
Wrote to stdout
$ ./writer.sh >(cat)
Wrote to file named /dev/fd/63These tend to be the same folks who think that using "sudo" is a waste of time and serves no purpose. Not that I've ever accidentally rebooted a box, of course. :P
Unfortunately, it does not log the output of the command. For those that need to log absolutely everything, check out:
https://github.com/jpschewe/rootsh
rootsh is a wrapper shell for bash and logs everything.