LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2007, 07:37 AM   #1
twofruits
LQ Newbie
 
Registered: Sep 2007
Posts: 1

Rep: Reputation: 0
Continious tailing of a log files, changing inodes


I have to write a script that will copy the output from a system log file, and place it into an area of the file system that is accessable via a webreport.

The easiset way is just to tail the output file and send it elsewhere, ie:-

tail ServerEngine.log > /opt/sw/reports/servereport.txt

However, the engine producing the log will zip up the original file and create a new one with the same name. The running tail process won't pick up the new file as it has a different inode.

I'm thinking the best way to approach this would be to find the inode based on the filename (ServerEngine.log) and start a process that tails that, sending the output to serverreport.txt

The script will monitor the inode number associated with ServerEngine.log in a loop, and when it notices a change, kill the original tail process and start a new one.

Can anyone think of a better way to do this ?
 
Old 09-14-2007, 11:57 PM   #2
osvaldomarques
Member
 
Registered: Jul 2004
Location: Rio de Janeiro - Brazil
Distribution: Conectiva 10 - Conectiva 8 - Slackware 9 - starting with LFS
Posts: 519

Rep: Reputation: 34
Hi twofruits,

What you need is the option "-F" on the tail. This option will tail the file by name instead of by inode; read "man tail".

Cheers,

Osvaldo.
 
  


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
Crazy scrolling when tailing remote file over ssh bram2000 Linux - Software 1 02-10-2006 09:06 AM
Deleted /var/log/messages, can't log any files-iptables chingyenccy Linux - Newbie 7 02-27-2005 04:03 PM
Changing log in screen antipop Linux - Software 8 07-06-2004 03:47 PM
iptables, changing log file from /var/log/messages acid2000 Linux - Networking 3 03-11-2003 08:38 PM
Can log files be time stamped? (such as FTP login and transfer log files) bripage Linux - Networking 6 08-08-2002 10:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:29 AM.

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