log_rotate.sh - Rotates log files
/opt/SUNWsamfs/examples/log_rotate.sh file [ minsize ]
The log_rotate.sh script rotates log files generated by Sun
Storage Archive Manager (SAM-QFS) environments and other
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:
o A given file never becomes so large that it is unwieldy
to copy or view.
o 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
SAM-QFS log file to make syslogd close and reopen the file
in its new location. This is not necessary for files
created by SAM-QFS processes because they check to see if
the file has been changed whenever it is opened.
The following are some of the SAM-QFS files you should
File Name or Type Location
SAM-QFS log file See /etc/syslog.conf for location.
/devlog files /var/opt/SUNWsamfs/devlog/.
Stage log files See /etc/opt/SUNWsamfs/stager.cmd
Releaser log files See /etc/opt/SUNWsamfs/releaser.cmd
Recycler log files See /etc/opt/SUNWsamfs/recycler.cmd
SEF data files /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:
file The log file to be rotated. For example, sam-log.
minsize 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/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
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 Sunday 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 Sunday at 0240.
The log_rotate.sh script resides in the following location: