This week, I'm based in S'pore performing a migration of Sun Java System Messaging Server from version 5.2 to 7.0u2 for an American bank.
They asked about log rotation - a question frequently asked.
Sun Java System Messaging Server provides numerous logs. What we are more concern with is the MTA log (mail.log, mail.log_current, and mail.log_yesterday).
If MTA log is enabled, then we need to pay attention to mail.log.
With logging is enabled, the mail.log file steadily grows and, if left unchecked, consumes all available disk space. Monitor the size of this file and periodically delete unnecessary contents. You can also delete the entire file as another version will be created as needed.
The message return job, which runs every night around midnight, appends any existing mail.log_yesterday to the cumulative log file, mail.log, renames the current mail.log_current file to mail.log_yesterday, and then begins a new mail.log_current file.
At this point, criticism comes in.
Why? No automatic log rotation? How can that be from an Enterprise product?
Well, I replied:
Sun is giving you the flexibility. :)
Anyway, to rotate mail.log is not too difficult on Solaris platform. We just need to learn about logadm.
You need to know that logadm is already configured out-of-the-box.
bash-3.00# crontab -l# The root crontab should be used to perform accounting data collection.#10 3 * * * /usr/sbin/logadm
All we need to do is to add a new entry into logadm.conf file.
bash-3.00# ls -al /etc/logadm.conf-rw-r--r-- 1 root sys 1485 Jun 11 03:10 /etc/logadm.conf
e.g. /appl/SJMS/log/mail.log -c -C 356 -t '$dirname/$basename.$n'
-c
Rotate the log file by copying it and truncating the original logfile to zero length, rather than renaming the file.
-C count
Delete the oldest versions until there are not more than count files left.
-t template
Specify the template to use when renaming log files.
$dirname
The directory of the file to be rotated
$basename
The log file name, without the directory name
$n
The version number, 0 is most recent, 1 is next most recent, and so forth
No comments:
Post a Comment