Database Reference
In-Depth Information
Here,
1>
instructs standard output to be redirected to the specified file. The
2>&1
instructs the shell script to send
standard error output to the same location as standard output.
■
For further details on how dBas use shell scripts and Linux features, see
Linux Recipes for Oracle DBAs
by
darl kuhn (apress, 2008).
Tip
Capturing Output with Linux/Unix Logging Commands
You can instruct Linux/Unix to create a log file to capture any output that is also being displayed on your screen.
This can be done in one of two ways:
tee
•
script
•
Capturing Output with tee
When you start RMAN, you can send the output you see on your screen to an OS text file, using the
tee
command:
$ rman | tee /tmp/rman.log
Now, you can connect to the target database and run commands. All the output seen on your screen will be
logged to the /
tmp/rman.log
file:
RMAN> connect target /
RMAN> backup database;
RMAN> exit;
The
tee
party session stops writing to the log file when you exit RMAN.
Capturing Output with script
The
script
command is useful because it instructs the OS to log any output that appears at the terminal to a log file.
To capture all output, run the
script
command before connecting to RMAN:
$ script /tmp/rman.log
Script started, file is /tmp/rman.log
$ rman target /
RMAN> backup database;
RMAN> exit;
To end a script session, press Ctrl+D, or type
exit
. The
tmp/rman.log
file will contain all output that was
displayed on your screen. The
script
command is useful when you need to capture all the output from a particular
time range. For example, you may be running RMAN commands, exiting from RMAN, running SQL*Plus commands,
and so on. The script session lasts from the point at which you start
script
to the point at which you press Ctrl+D.