log_rotate.sh - Rotates log files
∕opt∕SUNWsamfs∕examples∕log_rotate.sh
file
[ minsize ]
SUNWsamfs
The log_rotate.sh
script rotates log files generated by
Oracle Hierarchical Storage Manager (Oracle HSM) environments
and other programs.
The process of rotating log files assumes that you want to keep
no more than seven generations of a file in your directories at one time.
If the size of file is minsize or greater,
the files are rotated.
When the files are rotated, the newest file is renamed
file.1
, the next-newest file is renamed file.2
,
and so on. The oldest file in the directory is deleted as new
ones are added, so the oldest file in the directory at any time
is always called file.7
.
This process provides the following benefits:
A given file never becomes so large that it is unwieldy to copy or view.
Entries are expired after a period of time. This prevents file systems from filling up due to the volume of log entries.
You should send a HUP signal to syslogd
after rotating the Oracle HSM log file
to make syslogd
close and reopen the
file in its new location. This is not
necessary for files created by Oracle HSM processes because they check to see
if the file has been changed whenever it is opened.
The following are some of the Oracle HSM files you should consider rotating:
See ∕etc∕syslog.conf
for location.
∕devlog
files∕var∕opt∕SUNWsamfs∕devlog∕
.
See ∕etc∕opt∕SUNWsamfs∕stager.cmd
for location.
See ∕etc∕opt∕SUNWsamfs∕releaser.cmd
for location.
See ∕etc∕opt∕SUNWsamfs∕recycler.cmd
for location.
∕var∕opt∕SUNWsamfs∕sef∕sefdata
.
Note that the information in the archiver log is valuable and should be preserved. It should not be discarded after a short period of time.
This script accepts the following arguments:
The log file to be rotated. For example, sam-log
.
Specify an integer number, in bytes, that represents the minimum size
of the log file to be rotated. Log files smaller than this minimum
are not rotated. The default minsize is 100000
.
To enable this script, copy it from
∕opt∕SUNWsamfs∕examples∕log_rotate.sh
to ∕opt∕SUNWsamfs∕scripts∕log_rotate.sh
, modify it
to take the desired action for your installation, and
set up a crontab
(1) entry to run the log_rotate.sh
script.
The examples that follow assume that you have copied the script from
its location in ∕opt∕SUNWsamfs∕examples∕log_rotate.sh
to ∕opt∕SUNWsamfs∕scripts∕log_rotate.sh
.
Example 1.
Assume that you want to set up a crontab
(1) entry to run
the log_rotate.sh
script at a desired interval for each
of the log files you wish to rotate.
To rotate file sam-log
every week,
the entry would appear as follows:
10 3 * * 0 ∕etc∕opt∕SUNWsamfs∕scripts∕log_rotate.sh ∕var∕adm∕sam-log 20 3 * * 0 ∕bin∕kill -HUP `∕bin∕cat ∕etc∕syslog.pid`
This crontab
(1) file rotates
the ∕var∕adm∕sam-log
files
every day at 0310.
The second
line sends a HUP signal to the syslogd
daemon to notify it to close the
file (which has been moved) and open a new one. Note that this action
is only useful for files written by syslogd
.
Example 2. To rotate file releaser-log
every week,
the entry would appear as follows:
40 2 * * 0 ∕etc∕opt∕SUNWsamfs∕scripts∕log_rotate.sh ∕var∕adm∕releaser-log
This crontab
(1) file rotates
the ∕var∕adm∕releaser-log
files every day at 0240.
The log_rotate.sh
script resides in the following location:
∕opt∕SUNWsamfs∕examples∕log_rotate.sh
crontab
(1),
syslogd
(1M).