Skip to content

Instantly share code, notes, and snippets.

@nippyin
Forked from tuxfight3r/.bash_profile
Created January 17, 2021 22:43
Show Gist options
  • Save nippyin/adbba651f1c1b50004a640b9720bdd90 to your computer and use it in GitHub Desktop.
Save nippyin/adbba651f1c1b50004a640b9720bdd90 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