Rotational script of alert log file for Linux Operating System

Rotational script to rotate the alert log

Script help to rotate the alert log file or any log file.

You will need to provide the following parameter

ORACLE_SID : Name of the database

LOG_FILE: Location of the alert log file

It will rotate according to CRONTAB scheduled and it will rename old alert log file with prefix  date.

Note: Last statement in the script FOR remove the older file more than 30 days. you can change +30 to +90 for older than 90 days as your wish you can modified.

Script

#!/bin/bash
DATE_FORMAT=’date +”%Y”-“%m”-“%d”‘
ORACLE_SID=ORCL
LOG_FILE=/data01/alert/log
mv $LOG_FILE/alert$ORACLE_SID.log $LOG_FILE/alert$ORACLE_SID-$DATE_FORMAT.log
touch alert$ORACLE_SID.log

 
# Delete old log files more than 30 days you can change it by change +30 value to +60 for 60 days older and so on

find $LOG_FILE/alert*.log -mtime +30 -delete;

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s