Table of Contents

Linux Commands#Process Management

How to use script command in Linux

Help/Manual

# script -h

Usage:
 script [options] [file]
 -f, --flush             run flush after each write
 -a, --append            append the output
 -q, --quiet             be quiet


Tips

How to delete escape sequence and color code

$ cat LOSG | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?m//g" | col > log.txt


Examples

$ script -afq /tmp/test.log

How to logging automatically

LOGDIR=/var/log/script
script -afq ${LOGDIR}/$(whoami)_$(date +%Y%m%d_%H%M%S).log