script for Trimming the log files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for Trimming the log files
# 1  
Old 06-26-2012
script for Trimming the log files

Dear Gurus,

Trimming the alert log files of oracle. I need to write a script retaining last 20 lines of the log files and deleting all the other lines
I tried with tail -20 , Please help me how to delete all the other lines, my log files has grown upt to 2G.

Thanks in Advance
Dave
# 2  
Old 06-26-2012
What OS and version are you using?
# 3  
Old 06-26-2012
OEL 5.5
# 4  
Old 06-26-2012
The workflow could be:
Code:
cp -p altert.log alert.log.bk
tail -20  alert.log.bk >altert.log

This User Gave Thanks to Klashxx For This Post:
# 5  
Old 06-26-2012
Thanks for workflow, I am a new bie in linux , I tried with this script in the test environment and worked. I would also like to know is there any alarm when i am executing this script and at the same time if oracle tries to write to this log..

Thanks in Advance
Dave
# 6  
Old 06-27-2012
Block the alert_log file during the purgue , but I don't think that's a good idea.
The rotation should be very fast anyway. You hardly miss a message.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Trimming ends

My files look like this I need to remove the sequence GGGAAA and anything before that I also need to remove the sequence AGCCCTA and anything after that So I will end up with something like this The left side is done but I cannot get the right side correctly. I would like to use... (3 Replies)
Discussion started by: Xterra
3 Replies

2. Shell Programming and Scripting

Trimming in between the words

Hi i have a log file P12345_15728710:DEBUG:Begin P12345_15728710:DEBUG:Being P12345_15729310:DEBUG:GetAgen P12345_15726510:DEBUG:end i want to trim this file and i want like this 15728710 15728710 15729310 15726510 i tried sed ..but not working.. sed "s/.*P12345__ \(.*\)... (4 Replies)
Discussion started by: navsan420
4 Replies

3. Shell Programming and Scripting

How can I stop the unix script from trimming extra spaces?

I have a file which contains certain records about users. the row length is always fixed to 205 characters. Now I want to read each record line from the file, substring some portion out of it and put into another file. But I have observed that my script is trimming the extra spaces I have used for... (4 Replies)
Discussion started by: Pramit
4 Replies

4. Shell Programming and Scripting

trimming sequences

My file looks like this: But I would like to 'trim' all sequences to the same lenght 32 characters, keeping intact all the identifier (>GHXCZCC01AJ8CJ) Would it be possible to use awk to perform this task? (2 Replies)
Discussion started by: Xterra
2 Replies

5. Shell Programming and Scripting

trimming lines

hi have output as i have trim of lines before CREATE statement and lins after last ")" any idea how to achieve it ? (3 Replies)
Discussion started by: crackthehit007
3 Replies

6. UNIX for Advanced & Expert Users

Trimming the spaces

Hi, How can I remove the unwanted spaces in the line. 123456 789 ABC DEF. - I wanna remove the sapces in this line, I need the output 123456789ABCDEF. Pls help me...... (3 Replies)
Discussion started by: sharif
3 Replies

7. UNIX for Advanced & Expert Users

trimming zeros

Hi, I want to trim +with leading zero's with amount fields.I know using awk for trimming leading zeros with +,but I want get the entire row itself. cat file_name |awk -F " " '{printf "%14.4f%f\n",$4}' ex: 10 xyz bc +00000234.4500 20 yzx foxic +002456.000 Expexted 10 xyz bc... (3 Replies)
Discussion started by: mohan705
3 Replies

8. Shell Programming and Scripting

Trimming files concurrently

I have a file which is written by an ongoing process (actually it is a logfile). I want to trim this logfile with a script and save the trimmed portion to another file or display it to <stdout> (it gets picked up there by another process). Fortunately my logfile has a known format (XML) and i... (3 Replies)
Discussion started by: bakunin
3 Replies

9. Shell Programming and Scripting

Trimming a string

Hi, I am trying to find a script command that will let me trim leading and trailing space from a string. I have coded a SQL Select and sending the output to a file. Later I am parsing the file and reading each field. The problem is that each field uses the same size as the DB2 type it was defined... (2 Replies)
Discussion started by: fastgoon
2 Replies

10. UNIX for Dummies Questions & Answers

trimming a file...

Hi everyone I have this script that appends a line to a file to log the running status of an application. I need to write another script to run as a scheduled job in cron to trim the first x number of lines of this file. Could someone give me an idea how to do this? Regards (1 Reply)
Discussion started by: alwayslearningunix
1 Replies
Login or Register to Ask a Question