2013년 3월 15일 금요일

[TechNote] Rotating the plug-in log using UNIX commands

Rotating the plug-in log using UNIX commands


Question

How do I rotate the plug-in log?

Cause

The IBM WebSphere Application Server Web server plug-in does not come with a log rotation utility.

Answer

You can use the following UNIX commands to write a script to help with plug-in log rotation:

cd /opt/IBM/HTTPServer/Plugins/logs/webserver1

cp http_plugin.log http_plugin.log.`date +%Y-%m-%d-%T`

cat /dev/null > http_plugin.log
In this example, /opt/IBM/HTTPServer/Plugins/logs/webserver1 is where the plug-in log is created, and http_plugin.log is the plug-in log file name. The script will copy the existing plug-in log, append current time to the new log file name, and empty the existing log file.

A cron job can be scheduled using this script to rotate the plug-in log automatically. To do this, just copy the command above into a new txt file. Make sure the commands are correct for your specific environment, and make changes as needed. Make the txt file executable so that it can run as a script. Then, add an entry to your crontab to run the script. The values in the crontab entry will specify how often the script will be executed. For more information about crontab, please see your Unix OS specific documentation.

댓글 없음:

댓글 쓰기