Skip to content

Instantly share code, notes, and snippets.

@cameroncking
Created January 21, 2020 14:38
Show Gist options
  • Save cameroncking/8a34fe6ce94833af76e411567005c3df to your computer and use it in GitHub Desktop.
Save cameroncking/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