junxnone / linux

Linux wiki
https://junxnone.github.io/linux/
0 stars 0 forks source link

Tools script #6

Open junxnone opened 2 years ago

junxnone commented 2 years ago

script 记录终端执行命令历史

Reference

Brief

Usage:
 script [options] [file]

Make a typescript of a terminal session.

Options:
 -a, --append                  append the output
 -c, --command <command>       run command rather than interactive shell
 -e, --return                  return exit code of the child process
 -f, --flush                   run flush after each write
     --force                   use output file even when it is a link
 -o, --output-limit <size>     terminate if output files exceed size
 -q, --quiet                   be quiet
 -t[<file>], --timing[=<file>] output timing data to stderr or to FILE
 -h, --help                    display this help
 -V, --version                 display version
Usage:
 scriptreplay [-t] timingfile [typescript] [divisor]

Play back terminal typescripts, using timing information.

Options:
 -t, --timing <file>     script timing output file
 -s, --typescript <file> script terminal session output file
 -d, --divisor <num>     speed up or slow down execution with time divisor
 -m, --maxdelay <num>    wait at most this many seconds between updates
 -h, --help              display this help
 -V, --version           display version

UseCase

Usecase cmd
开始记录 script
保存记录到某个文件 script your/log/file
停止记录 exit
Ctrl+D
静默方式运行 script -q
$ script -t 2>cmd.time -a cmd.his
...
run some command
...
$ exit
$ scriptreplay cmd.time cmd.his