For DBAs, you often encounter database upgrades or apply patches, and sometimes need to run a large number of scripts. For these operations, we want to output files simultaneously on the screen for subsequent steps or errors that have been lost during query. Script Commands in Linux are a good helper to solve this problem.
1. script command description
The script command will record all operations to the file and output them on the screen at the same time until the login session is terminated, or use CRTL + D, or exit with exit to stop the record.
This command can be used for database upgrades or important settings for subsequent query operations to succeed or fail.
Usage: $ script [upgrade. log]
If no log file name is specified, the log file name is automatically generated as typescript.
If you need to output to an existing Log File, use the-a parameter, and then connect the existing log file name.
If you want to view the content of a log file while outputting it to a log file, you can use the-f parameter.
# Script help description
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
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
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.