Skip to content

Instantly share code, notes, and snippets.

@ckxng
Created January 21, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckxng/8a34fe6ce94833af76e411567005c3df to your computer and use it in GitHub Desktop.
Save ckxng/8a34fe6ce94833af76e411567005c3df to your computer and use it in GitHub Desktop.
log user commands
function log2syslog
{
declare COMMAND
COMMAND=$(fc -ln -0)
TTY=$(tty)
TTYOWNER=$(stat -c ‘%U’ ${TTY})
logger -p local1.notice -t bash -i -- “${TTY}:${TTYOWNER}:${USER}:${COMMAND}"
}
trap log2syslog DEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment