User Tools

Site Tools


wiki:record_terminal_sessions

This is an old revision of the document!


Record terminal sessions

Multiple ways to log terminal sessions in file.

Add to end of .bashrc to start recording session when you open the terminal.

script program

We test for shell's parent process not being script and then run script

test "$(ps -ocommand= -p $PPID | awk '{print $1}')" == 'script' || (script -f $HOME/Documents/terminal_logs/$(date +"%d-%b-%y_%H-%M-%S")_shell.log)

To read the log use “less -R” (see this too https://superuser.com/questions/236930/how-to-clean-up-output-of-linux-script-command)

asciinema

apt install asciinema
test "$(ps -ocommand= -p $PPID | awk '{print $1}')" == 'sh' || (asciinema rec $HOME/Documents/terminal_logs/$(date +"%d-%b-%y_%H-%M-%S").cast)

python program TermRecord

pip3 install TermRecord
test "$(ps -ocommand= -p $PPID | awk '{print $1}')" == 'script' || (TermRecord -o $HOME/Documents/terminal_logs/$(date +"%d-%b-%y_%H-%M-%S").html)

Tested on

  • Ubuntu 20.04.3

See also

References

wiki/record_terminal_sessions.1641555343.txt.gz · Last modified: 2022/01/07 11:35 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki