about log errors


 
Thread Tools Search this Thread
Operating Systems Solaris about log errors
# 1  
Old 06-22-2010
about log errors

How would you truncate a log file that is growing too large if you don't have space to compress it or to move it somewhere else? How would you do it?
# 2  
Old 06-22-2010
GNU sed has an inline editing function to perform on files.

delete reasonable amount of the file from the start using 'sed'

Code:
sed -i '1,1000d' filename

this will delete first 1,000 lines from file without need of a temp file.
# 3  
Old 06-22-2010
If you don't want to keep the contents:
Code:
: > file.log

If you want to keep the contents:
Code:
 perl -e 'open $fh,"<file.log"; \
@bla=<$fh>; close "file.log"; unlink "file.log"; open $fh,"|gzip -9c"; \
print $fh @bla; close $fh;' > file.gz

Change file.log to the correct name where needed.

Last edited by pludi; 06-22-2010 at 04:10 AM.. Reason: corrected formatting
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Outputting Errors to a Log file

Good Morning, Every so often, I have copy scripts that to don't complete, but I don't immediately know why. It usually ends up being a permissions issue or a length issue. The scripts edit a log file, so I'd like to include any copy errors/issues in that file to check if the copies... (4 Replies)
Discussion started by: Stellaman1977
4 Replies

2. Solaris

Can't Log into Solaris 10 u10 due to Pam and DH errors

Dears,, i hope everything is going fine with you,, Yesterday i was trying to log into My Solaris 10 u10 x86 Via SSH , But it showing me many error message and refusing to login even with with the root account and below you can find the error message: # ssh -v root@192.168.10.1... (6 Replies)
Discussion started by: ieee99
6 Replies

3. Shell Programming and Scripting

Scan log file for errors

Hi everyone. I am still new to UNIX, and am having trouble figuring out how to create a script to scan a log file to look for errors based on a string. We run AIX 5.3, and would like the ability to report all the instances of WebSphere Broker Execution groups crashing. This script would... (8 Replies)
Discussion started by: jimbojames
8 Replies

4. Shell Programming and Scripting

Finding errors in log file only in last 10 minutes

Hi there, I have a log file that I need to check every 10 minutes to find if a specific error exists but only in that 10 minute period. The reason is that the log is quite large, and will frequently contain these errors, so I only want alerting if it in the last 10 minutes - I don't want... (3 Replies)
Discussion started by: paul_vf
3 Replies

5. Shell Programming and Scripting

Capturing errors messages into log file

Can we capture and write all the error messages which were being displayed on the command prompt screen during execution of a program into a log file? If yes, can anyone please let me know on how to do it? I am using ksh and working on AIX server. Thank you in advance. (4 Replies)
Discussion started by: vpv0002
4 Replies

6. UNIX for Dummies Questions & Answers

Log in as root and it errors out

Hello I tried to log in as root, through console access, and this is what I got. >root ksh: root: not found Can you tell me why I got this and what causes it. Thanks. (2 Replies)
Discussion started by: iamnew2solaris
2 Replies

7. Shell Programming and Scripting

track the errors in log file

OS: SuSE Linux Enterprise Server 10 Goal: To track the errors in log file, If they exits users will be notify by email. We have a script below: SrchKey="SRVE0242I:" LogFile=/PATHtemOut.log MailTo="DN@mail.com http:// ! -f PATH/alert.last && touch PATH/alert.last egrep $SrchKey $LogFile... (3 Replies)
Discussion started by: sdhn1900
3 Replies

8. UNIX for Advanced & Expert Users

filter errors in log

is there anyway i can filter/ignore specific error messages in the /var/log/messages? (1 Reply)
Discussion started by: modcan
1 Replies

9. Shell Programming and Scripting

redirect errors to log file

I am working on a generic script that will run a shell script with the arguments passed and redirect errors to one file, and all other output to another file. Then if there is anything in the error file it emails the error to me, otherwise it exits. The advantage for this approach is that I... (0 Replies)
Discussion started by: gandolf989
0 Replies
Login or Register to Ask a Question