Live data from Hacker News

How To Log Bash History to Syslog

jablonskis.org

1–10 of 14 posts

Re: How To Log Bash History to Syslog

#4
post #2

What does history -a do? Seems to write the history to disc and not produce something to pipe into logger. How does this work?

With bash putting a command in 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.

Re: How To Log Bash History to Syslog

#5
post #4
post #2

What does history -a do? Seems to write the history to disc and not produce something to pipe into logger. How does this work?

With bash putting a command in 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.

Yup, that's what it does. Shortly speaking () in bash that creates a temporary pipe.

Re: How To Log Bash History to Syslog

#7
i would be a bit worried about accidental passwords getting into the syslog. i have typed passwords out of habit when they were not required or before a remote system responds only to have the password end up as a bash command. i then have to go into the .bash_history file and remove them.

Re: How To Log Bash History to Syslog

#8
post #7

i would be a bit worried about accidental passwords getting into the syslog. i have typed passwords out of habit when they were not required or before a remote system responds only to have the password end up as a bash command. i then have to go into the .bash_history file and remove them.

Agreed - folks who are logged in as root a lot seem to have an uncanny tendency to type all kinds of stuff that probably shouldn't show up in a log anywhere.

These 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

Re: How To Log Bash History to Syslog

#10
post #3
post #2

What does history -a do? Seems to write the history to disc and not produce something to pipe into logger. How does this work?

It appends the "new" history lines to a $HISTFILE by default, unless other file is specified.

Thanks, that's what I was missing: -a can have a file. Cool stuff and thanks to all for explaining it. http://unixhelp.ed.ac.uk/CGI/man-cgi?history does not mention the command line argument, http://linux.die.net/man/1/bash does.
Post reply on HN