Help needed on Perl Script to Handle Log files that are rotated using logrotate


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed on Perl Script to Handle Log files that are rotated using logrotate
# 1  
Old 10-12-2012
Help needed on Perl Script to Handle Log files that are rotated using logrotate

Hello all,

I am working on a perl script which will read weblogic logfile and send the error messages to Zenoss Monitoring tool. At present the script works and it can able to send the error messages to Zenoss. The problem comes when the logrotate has been applied to the weblogic log file. At that time the script couln't able to read the log file since the logfile content has been shifted to log_file.1. Can you please help how can i handle this situation in Perl script.

Regards
Karthik
# 2  
Old 10-12-2012
In general scripting pseudo-code, create a marker file with the last line # you examined in it immediately at the end of the scan. On the next pass, find files newer than the marker file and concatenate them to standard in, discarding the number of lines in the marker file. This way, the script only sees new lines from new files. If during the last scan there were logs log1 to log87 and log being written, and you saw 3214 lines of that file, later when you return there might be logs log1 to log99, but you want to start after line 3214 of log88 examining through log99 and then log.
# 3  
Old 10-26-2012
Thanks DGPickett , As per your instruction i have created the script Can you please tell me how to test this scenario with out actual logrotation. As i dont have neccessary prvilages to do that . Moreover i am new to unix environment.
# 4  
Old 10-26-2012
You can make a copy of the system logs in a space where you have space and write permissions, updating it periodicially using cpio or rsync, and test on that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logrotate - I am not able to rotate files using logrotate

I have written script which is working in Home directory perfectly and also compressing log files and rotating correctly. But, when i try to run script for /var/log/ i am able to get compressed log files but not able to get rotation of compressed log files. Please suggest. I am using below command... (5 Replies)
Discussion started by: VSom007
5 Replies

2. Debian

Logrotate truncated my log files to 0 bytes and no logs are written

Hi, Yesterday I installed and configured logrotate on my Debian machine. I was expecting this to run at 06:25 in the morning and it actually did. All my old logs were compressed and zipped but the new logs were all with size equal to 0 bytes. Processes, while still running ok, they were not... (2 Replies)
Discussion started by: pmatsinopoulos
2 Replies

3. Shell Programming and Scripting

Help needed with Perl Script

i have the following script: #!/usr/local/bin/perl use STUN::Client; use Data::Dumper; use strict; my $stun_client = STUN::Client->new; $stun_client->stun_server('10.59.29.14'); my $r = $stun_client->get; my $ip = $r->{ma_address}; print "IP: $ip\n\nResult (hash):... (5 Replies)
Discussion started by: SkySmart
5 Replies

4. Shell Programming and Scripting

Help needed urgently. Look back for files in PERL

I have 3 variables $file =abc_2011_11_01.txt (current day file) $back = Yes $forward = No I need to search for 3 days back files / 3 days forward files if my current file is not present logic is, I need to download the current day file. If it is missing, i need to look out for... (1 Reply)
Discussion started by: irudayaraj
1 Replies

5. Shell Programming and Scripting

A small help needed in Logrotate

Hi, I wanted to know can a custom script can be made available to run in postroate endscript something like postrotate ./scriptpath/sh-script.sh endscript Is this the correct syntax, or it will require any modification? Thanks in Advance. Neeryan (1 Reply)
Discussion started by: Neeryan
1 Replies

6. Shell Programming and Scripting

Perl script needed

For the following command I need a perl script equivalent with a couple of more things - cat /tmp/mail |grep Appname > /tmp/mail1;cat /tmp/mail >> /tmp/mail1; mail -s "mail subject here" allan@mail.com < /tmp/mail1; >/tmp/mail ; >/tmp/mail1 ================== cat /tmp/mail ***** Alert *****... (4 Replies)
Discussion started by: jacki
4 Replies

7. Shell Programming and Scripting

Perl script help needed..

Hi, I am new to perl scripting. Can anybody help me in solving the below problem. I have file, which is called map_file. According to map_file's last column data, i need a output file, which has repeats as like the map_file's last column name. Thank you in advance Vasanth (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

8. Shell Programming and Scripting

Perl Script Help Needed

I need this script to be able to check both IPs that are given to it and exit with an OK... if one of those expected IPs is returned. The script is run like this: /bin/dns_checker.pl -s 69.34.55.66 -q htt.jababa.com -e 69.44.56.33,45.47.43.55 Right now, the script is failing, but when I... (4 Replies)
Discussion started by: SkySmart
4 Replies

9. UNIX for Advanced & Expert Users

how to logrotate log files

Hi, I have written a script that runs every five minutes in cron schedular. The Operating system is Fedora core 9. This script generates 2 log files, these log file size is increasing as some log data is being dumped into these 2 log files every five minutes. I need to logrotate these 2 files.... (1 Reply)
Discussion started by: renuka
1 Replies

10. Shell Programming and Scripting

flexible sed command needed to handle multiple input types

Hello, I need a smart sed command that can take any of the following two as an input and give below mentioned output. As you can see, I am trying to convert some C code INPUT: struct abc_sample1 { char myString; UINT16 myValue1; ... (2 Replies)
Discussion started by: SiftinDotCom
2 Replies
Login or Register to Ask a Question