LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices



Reply
 
Search this Thread
Old 10-31-2012, 11:25 AM   #1
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 196

Rep: Reputation: 30
Problem running tail -f against oft-truncated file


howdy folks,

I want to monitor a log file for a specific event and grab an iostat the moment the event is detected. The bash function below works fine until the file gets renamed (logfile.nnn.txt), gzipped (logfile.nnn.txt.gz), moved (mv logfile.nnn.txt.gz ./backup_logs) and re-created (touch logfile.txt). Once it's truncated it ceases to work.

tail -f logfile.txt | while read INFILE
do
[[ "${INFILE}" == *"event_12345"* ]]
&& iostat -t >> iostat_when_process_times_out.txt
&& beep
done

Need solution so that I can still monitor the log for the event and capture an iostats when it happens. Any help would be greatly appreciated. Thanks.
 
Old 10-31-2012, 01:15 PM   #2
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 196

Original Poster
Rep: Reputation: 30
Hey I think I fixed it.

I did two things:
1. created a symbolic link to the logfile
2. Instead of running "tail -f" I tried with "tail -F" (capital F) which looks like it includes a retry function. The function spit out this message:
tail: `tempsymboliclink_logfile' has been replaced; following end of new file

And I'm sitting pretty with an iostats log. My guess is it's the tail option, not the symbolic link that mattered but it's working as-intended.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] ar: .libs/libbfd.a: Error reading archive.o: File truncated grail Programming 4 06-01-2010 07:28 PM
[SOLVED] redirecting output, observe with tail -f <file>, while running, without screen? srons Linux - Newbie 3 04-22-2010 07:43 AM
Recover truncated file's contents on XFS? Tomasu Linux - Server 10 04-29-2008 09:08 AM
Help! tar file's name is truncated auden Linux - Newbie 1 03-02-2005 10:09 PM
Perl file conversion results in a truncated file kshaffer Programming 0 01-31-2005 03:31 PM


All times are GMT -5. The time now is 07:33 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration