当前位置:Gxlcms > mysql > Linuxscript命令记录(数据库)操作步骤

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

时间:2021-07-01 10:21:17 帮助过:46人阅读

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

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

1、script命令描述

script命令会记录所有的操作到文件同时在屏幕上输出,直到终止登陆的会话,或使用CRTL+D,或使用exit退出则停止记录。
这个命令对于数据库的升级或是重要设置的情形下使用可以用于后续查询操作成功或失败。
用法: $ script [upgrade.log]
如果未指定日志文件名的情形,自动生成日志文件名为typescript。
如果需要输出到已经存在的日志文件,则使用 -a 参数,再接已经存在日志文件名。
如果需要在输出到日志文件的同时,也可以查看日志文件的内容,可以使用 -f 参数。

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

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

DESCRIPTION
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.

Options:

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

-c COMMAND
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.

linux

人气教程排行