How UNIX/AIX handles a file deep down, say it's being read while another one tries to rename it?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How UNIX/AIX handles a file deep down, say it's being read while another one tries to rename it?
# 1  
Old 01-05-2010
How UNIX/AIX handles a file deep down, say it's being read while another one tries to rename it?

Hi Thinkers,

On AIX 5.3, we have a monitor program that reads the log file and searching for a certain string pattern that we define(say "transactionException"), if it sees it then it will raise an alert by sending an email.

Because the log file XXX.log is rolling into XXX.log.0, XXX.log.1, XXX.log.n...etc when a certain condition(size, time/date) meets, now my question is, is that possible that when the application generates the string "transactionException" and then it got rolled/renamed into XXX.log.0 before the monitor program sees it ? The monitor program is configured to monitor XXX.log file only ?

I am not sure how the monitor program is coded so I'd like to ask this way, if you are developing such monitor tooling, what you'd think to avoid the senario that I described above? I believe this may be to do with how Unix handle file deep down at the very low level ...


Your knowledge on this is much appreciated.

Thanks a ton.

Thegunman
# 2  
Old 01-05-2010
If each log file entry has a date stamp alongside it then the monitoring process could keep track of the alerts it has already seen and then it could look at the tail end of XXX.log.0 as well as the contents of XXX.log?

The better solution would be for the monitoring software to roll the log files it is looking at so that it can do the log file rolling directly after checking the log file.

Another way round it is that the code rolling the log files does this:
Code:
mv XXX.log XXX.log.0
tail -3 XXX.log.0 >> XXX.log

So that the tail end of XXX.log.0 is retained in XXX.log, this would cause log file entries to be in more than one file. I suggested appending the tail end of XXX.log.0 onto XXX.log just in case some new entries have already been put into XXX.log.
# 3  
Old 01-08-2010
thanks a lot for your reply !! TFM!

The monitoring process has to be transparent to the application so it can only do read to the file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read contents in each file and rename the file?

Hello All, Can you help me in writing a script for reading the specific position data in a file and if that data found in that file that particular file should be renamed. Ex: Folder : C:\\test and Filename : CLSACK_112214.txt,CLSACK_112314.txt,CLSACK_112414.txt Contents in the file would... (3 Replies)
Discussion started by: nanduedi
3 Replies

2. UNIX for Dummies Questions & Answers

Script to leak file handles

This is a strange one. We have an issue where our system is leaking SCTP file handles. There are people working on this and in the mean time we have a monitoring script that alarms when we need to perform actions to manually clear them. For testing purposes I want to write a script that... (0 Replies)
Discussion started by: RECrerar
0 Replies

3. UNIX for Dummies Questions & Answers

Help with Unix file rename

Hi All, I have a unix file which is ceated with variable name, for example: FIRST_FILE_3456 and next time it will be FIRST_FILE_3457 and so on. I need to rename this file like PREV_FIRST_FILE_XXXX where XXXX is the variable part of the file FOR Example 3456 or 3457, etc. Please help to... (4 Replies)
Discussion started by: Mohammad T Khan
4 Replies

4. UNIX for Advanced & Expert Users

sendmails works, but opens 43 file handles per email -> problem

I'm using Sendmail 8.13.8 on a CentOS 5.5 vServer (Virtuozzo). I'm using a loop in PHP to send a lot of HTML-mails via sendmail. Each mail is a mail with individual statistics for our users, so its not mass mailing, bcc is not an option. It all works fine, but when I take a closer look there... (2 Replies)
Discussion started by: ZX81
2 Replies

5. Shell Programming and Scripting

Rename a file sequencially in UNIX

I need to be able to look for the last file in a dirctory in UNIX, the file satrt with EFT so this work file=$(ls -tr $EFT*.dat | tail -1) # Select the latest file my last file is EFT1234.dat then I need to be able to get a file that I just ftp and rename with this name EFT1234.dat but... (5 Replies)
Discussion started by: rechever
5 Replies

6. Shell Programming and Scripting

Read File and use contents to rename another

Hello guys, thank God that I found this forum. I hope that someone can help me because I don't have any idea on how to start it. I know that for some of you this is a very simple task but I'm not as advance on shell scripting like many people out there. I got this file with a permanent... (10 Replies)
Discussion started by: Shark Tek
10 Replies

7. Shell Programming and Scripting

Monitor open file handles used by a process

We have a process that is running out of file handles. Is there some command line way to determine this that we can include into a cron script? Please let me know JAK (3 Replies)
Discussion started by: jakSun8
3 Replies

8. Shell Programming and Scripting

perl help with pipes and file handles (simple issue)

Hello, I have a program which opens a pipe for communication using file handle and forks 5 child processes. @waitlist = (1,2,3,4,5); foreach $item (@waitlist) { pipe *{$item},RETHAND; unless ($pid = fork()) { # Child process print RETHAND... (1 Reply)
Discussion started by: the_learner
1 Replies

9. Shell Programming and Scripting

SSH in batch mode and File-Handles in a loop

Hi all I try to execute SSH commands on several hosts in a while-loop. There seems to be a problem with file-handle, first cycle works correct but no other one will follow due to the while condition is false even that there are many more host entries (lines) in all_hosts.dat. ... (3 Replies)
Discussion started by: DaveCutler
3 Replies

10. UNIX for Advanced & Expert Users

File Handles

Hi, perhaps you can answer my question.....;) How can I check, how many file handles are used and how can i increase the value for maximum file handles??? (3 Replies)
Discussion started by: sjaeger
3 Replies
Login or Register to Ask a Question