-
-
Save nippyin/adbba651f1c1b50004a640b9720bdd90 to your computer and use it in GitHub Desktop.
bash history log all commands to syslog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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