Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Last active March 31, 2021 10:54
Show Gist options
  • Save tuxfight3r/af954e09e0e95810fa4a968996e77f1c to your computer and use it in GitHub Desktop.
Save tuxfight3r/af954e09e0e95810fa4a968996e77f1c to your computer and use it in GitHub Desktop.
bash history log all commands to syslog
#log all your bash command to syslog
function log2syslog
{
declare COMMAND
COMMAND=$(fc -ln -0)
logger -p local1.notice -t bash -i -- "${USER}:${COMMAND}"
}
trap log2syslog DEBUG
#moredetails can be found here
#http://mywiki.wooledge.org/BashFAQ/077
PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment