Friday 13 January 2017

How to Rotate log file in Linux or oracle easy steps with example


Hi Friends, 
Today, One more very importance and useful real time experiences sharing with you all. 
Logrotate is one type of utility or method which is designed for a DBA or administrators through which we can manage such servers producing a high volume of log files. Or at a time suddenly log file sizes is increasing. 

This happened recently with us; One day suddenly our mount point was increasing highly in Test instance. Then we thought to about housekeeping. Then we logged into server and checked, but there was nothing to remove the files. 

Then we thought to let’s see the alert log, and we came to know that other team doing some things and because of that alert log size is increasing, and we are getting the alert for file system reaching threshold. 
Then we decided to “Rotate” the log file. As we searched in Google but there was confusion and we got a lots of commands. Which we don’t want take any risk unnecessarily. 
Then we prepare this below commands which are very easy and helpful steps. 

Suppose, here our log file name is ora-data.log and our back mount point is /backup.

1. We will copy the log file to Backup mount points as shown below. 
cp -p ora-data.log /backup 

2. Then use the below command very carefully to Rotate the log file. From this command, log file will be 0(zero) bytes and again it will restart to write the file. 

cat /dev/null > ora-data.log 

3. Go to backup location and zipped the copied log file as shown below command.  We are zipping file because file size will be small and we can again put this at original location.

gzip /backup/ora-data.log 

4. We should restore the zipped ora-data.log file from back to original location for future references. 

i.e. cp -p ora-data.log.gzip /ora-data/  << this patch should be original alert log path.

In short Steps: 
1. cp -p ora-data.log /backup 
2. cat /dev/null > ora-data.log 
3. gzip /backup/ora-data.log.

And then restore the backup gzip file to original location. 
For details, Please refers the above steps details. 

You may like below points:

Real Time Experiences Sharing

Oracle Database


Oracle Apps
 
Redo Log


Job Tips 

Hope this will be useful. For any suggestions and query, please write to us either by comments or our contact us. 

Thanks,

2 comments:

  1. Superb post I savored looking through this and I defiantly will recombed
    this article in direction of my close friends moreover I
    will have toward posting this on Facebook, twitter and a lot more.

    I appear which include this really should be shared
    in the course of the world wide web. I’ve been within the
    engineering current market for about a ten years and I constantly appreciate studying contemporary
    articles that could possibly most likely aid me be a lot more professional inside my marketplace.
    I appear which includes I received a whole lot out of what oneself wrote and I’m enthusiastic in the direction of share this with my relatives and
    good friends.

    ReplyDelete
  2. Its like you read my mind! You appear to know a loot about this, like you
    wrote the book in it or something. I think that you could do with a few pics to drve thhe message home a little bit, but instead of that, this is wonderful blog.
    A great read. I'll definitely be back.

    ReplyDelete

Thank you for your comments and suggestions. It's good to talk you.