Skip to content

Instantly share code, notes, and snippets.

@bilalatli
Forked from kaanklky/etc-profile
Created July 14, 2019 13:40
Show Gist options
  • Select an option

  • Save bilalatli/7610055be4ae9ae3c8c4ea9b7fcaef3c to your computer and use it in GitHub Desktop.

Select an option

Save bilalatli/7610055be4ae9ae3c8c4ea9b7fcaef3c 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