Skip to content

Instantly share code, notes, and snippets.

@kaanklky
Last active July 14, 2019 13:40
Show Gist options
  • Select an option

  • Save kaanklky/e600bd0c55238429ec2122200e0bdefd to your computer and use it in GitHub Desktop.

Select an option

Save kaanklky/e600bd0c55238429ec2122200e0bdefd to your computer and use it in GitHub Desktop.
Save terminal sessions
#Record terminal sessions
if [ "x$SESSION_RECORD" = "x" ]
then
TTY_CON=$(tty | cut -d '/' -f3)/$(tty | cut -d '/' -f4)
TTY_IP=$(who | grep "${TTY_CON}" | cut -d ' ' -f16 | tr -d '()')
output=/var/log/session/session_$(date +%F_%H-%M-%S)_$USER.$TTY_IP
SESSION_RECORD=started
export SESSION_RECORD
script -t -f -q 2>${output}.timing $output
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment