Linux script 命令记录(数据库)操作步骤

对DBA而言,经常碰到升级数据库或是apply patch,以及有些时候需要运行大量的脚本。对于这些操作我们希望现在在屏幕同时又输出的

对DBA而言,经常碰到升级数据库或是apply patch,,以及有些时候需要运行大量的脚本。对于这些操作我们希望现在在屏幕同时又输出的文件以备后续查询过程中曾经丢失的步骤或错误。Linux下的script命令就是解决这个问题的好帮手。


用法: $ script [upgrade.log]
如果需要输出到已经存在的日志文件,则使用 -a 参数,再接已经存在日志文件名。
如果需要在输出到日志文件的同时,也可以查看日志文件的内容,可以使用 -f 参数。

# script 帮助描述
robin@SZDB:~> man script
script - make typescript of terminal session

script [-a] [-c COMMAND] [-f] [-q] [-t] [file]

Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of
an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the
file typescript.


-a Append the output to file or typescript, retaining the prior contents.

Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a pro-
gram that behaves differently when its stdout is not a tty.

-f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and
another can supervise real-time what is being done using `cat foo'.

-q Be quiet.

-t Output timeing data to standard error. This data contains two fields, separated by a space. The first field indi-
cates how much time elapsed since the previous output. The second field indicates how many characters were output
this time. This information can be used to replay typescripts with realistic typing and output delays.