LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-30-2013, 02:37 PM   #1
Rohant
Member
 
Registered: Oct 2011
Location: India, Mumbai
Distribution: RHEL, Fedora,Ubuntu, Centos, Windows XP & Windows 7
Posts: 44

Rep: Reputation: Disabled
Log parsing but issue with log rotation


Hi all,

i am planning to implement log parsing on my kannel application server for easy log searching for me.

one of our developer gave me log parsing script as per my need which is written in perl & the script is doing its job perfectly.

I am facing the issue only at the time of Log rotation which happens at every night at 12 am.

my log get write in "/var/log/kannel/kannel_access.log" file & at the time of log rotation yesterdays log file gets rename to "kannel_access.log.1" & new "kannel_access.log" file gets created. more than 1 days old file gets archive in .gz format.

when my log parsing script (logparser.pl) is running in background & keeps watch on "kannel_access.log" file what ever logs get written in that file it take required values from the file & stores it in database tables.

issue that i am facing is at the log rotation i run prerotate script like below.

==============
kill -ABRT `ps auxf | grep "[p]erl logparser.pl" | awk '{print $2}'`
==============

after i run postrotate script as below.

==============
killall -HUP bearerbox smsbox wapbox || true > /dev/null 2> /dev/null
cd /root/logparser/
/usr/bin/perl logparser.pl log_parsing_configuration_rxkannel.conf &
==============

but my perl script (logparser.pl) keeps on running. after log rotation it should write log in newly created "/var/log/kannel/kannel_access.log" file but it keeps on writing in yesterday log file which now became "/var/log/kannel/kannel_access.log.1" after log rotation.

I simply want at the time of log rotation the log parsing script (logparser.pl) should get pause till my log rotation happens & till new log file get created. after the log rotation & after creation of new "kannel_access.log" file it should start writing logs in the newly created "kannel_access.log" file.

hope i mentioned my issue properly.

please if you have any suggestion on above or if i made any mistake or missed something kindly let me know.
 
Old 05-30-2013, 09:09 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You need to get the programmer to add signal handlers for eg SIGUSR1 to stop reading (ie close handle on that 'old' file), & SIGUSR2 to start reading (open handle on new file).
If a prog doesn't have an explicit SIG handler, it'll do nothing or whatever the system default is (if anything), which usually only applies to things like SIGKILL, SIGTERM etc.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Log rotation of log files in different directories mahi_nix Linux - Server 7 02-19-2013 05:33 AM
Syslog-ng messages.log log rotation Iyyappan Linux - Server 3 09-16-2012 11:10 AM
Need Help on Log Rotation. manoj.linux Solaris / OpenSolaris 1 04-26-2012 03:46 AM
How to change Debian log rotation of syslog and daemon.log onmountain Linux - Newbie 2 07-31-2008 02:27 AM
Log Rotation for snort log does not seem to be working CentOS4.5 JasonKretzer Linux - Security 3 06-25-2007 12:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration