Sponsored Content
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? Post 302384409 by TheGunMan on Tuesday 5th of January 2010 08:19:01 AM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
multilog(8)						      System Manager's Manual						       multilog(8)

NAME
multilog - reads a sequence of lines from stdin and appends selected lines to any number of logs. SYNOPSIS
multilog script DESCRIPTION
script consists of any number of arguments. Each argument specifies one action. The actions are carried out in order for each line of input. Note that actions may contain shell metacharacters that need to be quoted when multilog is run from a shell. multilog exits 0 when it sees the end of stdin. If stdin has a partial final line then multilog inserts a final newline. multilog writes a message to stderr and exits 111, without reading any input, if it runs out of memory or if another multilog process is writing to one of the same automatically rotated logs. If multilog has trouble writing to disk after it starts reading input, it writes a message to stderr, pauses, and tries again, without los- ing any data. Note that this may block any program feeding input to multilog. If multilog receives a TERM signal, it will read and process data until the next newline, and then exit, leaving stdin at the first byte of data it has not processed. SELECTING LINES
Each line is initially selected. The action -pattern deselects the line if pattern matches the line. The action +pattern selects the line if pattern matches the line. pattern is a string of stars and non-stars. It matches any concatenation of strings matched by all the stars and non-stars in the same order. A non-star matches itself. A star before the end of pattern matches any string that does not include the next character in pattern. A star at the end of pattern matches any string. For example, the action +hello selects hello. It does not select hello world. The action -named[*]: Cleaned cache * deselects named[135]: Cleaned cache of 3121 RRs. The first star matches any string that does not include a right bracket. The action -* deselects every line. To save memory, multilog actually checks pattern against only the first 1000 characters of each line. ALERTS
The action e prints (the first 200 bytes of) each selected line to stderr. STATUS FILES
The action =file replaces the contents of file with (the first 1000 bytes of) each selected line, padded with newlines to 1001 bytes. There is no protection of file against power outages. For example, the sequence of actions -* +STAT* =log/status maintains log/status as a copy of the most recent line starting with STAT. TIMESTAMPING
The action t inserts an @, a precise timestamp, and a space in front of each line, using the same format as tai64n(8). This is required to be the first action. Patterns apply to the line after the timestamp is inserted. For example, if multilog t '-*' '+* fatal: *' ./main reads the line fatal: out of memory then it will log a line such as @400000003b4a39c23294b13c fatal: out of memory with the first * matching the timestamp. You can use tai64nlocal(8) to convert these timestamps to human-readable form. AUTOMATICALLY ROTATED LOGS
If dir starts with a dot or slash then the action dir appends each selected line to a log named dir. If dir does not exist, multilog creates it. Do not attempt to write to one log from two simultaneous multilog processes, or two actions in one process. The log format is as follows. dir is a directory containing some number of old log files, a log file named current, and other files for multilog to keep track of its actions. Each old log file has a name beginning with @, continuing with a precise timestamp show- ing when the file was finished, and ending with one of the following codes: .s This file is completely processed and safely written to disk. .u This file was being created at the moment of an outage. It may have been truncated and has not been processed. Beware that NFS, async filesystems, and softupdates filesystems may discard files that were not safely written to disk before an outage. While multilog is running, current has mode 644. If multilog sees the end of stdin, it writes current safely to disk, and sets the mode of current to 744. When it restarts, it sets the mode of current back to 644 and continues writing new lines. When multilog decides that current is big enough, it writes current safely to disk, sets the mode of current to 744, and renames current as an old log file. The action ssize sets the maximum file size for subsequent dir actions. multilog will decide that current is big enough if current has size bytes. (multilog will also decide that current is big enough if it sees a newline within 2000 bytes of the maximum file size; it tries to finish log files at line boundaries.) size must be between 4096 and 16777215. The default maximum file size is 99999. In versions 0.75 and above: If multilog receives an ALRM signal, it immediately decides that current is big enough, if current is nonempty. The action nnum sets the number of log files for subsequent dir actions. After renaming current, if multilog sees num or more old log files, it removes the old log file with the smallest timestamp. num must be at least 2. The default number of log files is 10. The action !processor sets a processor for subsequent dir actions. multilog will feed current through processor and save the output as an old log file instead of current. multilog will also save any output that processor writes to descriptor 5, and make that output readable on descriptor 4 when it runs processor on the next log file. For reliability, processor must exit nonzero if it has any trouble creat- ing its output; multilog will then run it again. Note that running processor may block any program feeding input to multilog. SEE ALSO
supervise(8), svc(8), svok(8), svstat(8), svscanboot(8), svscan(8), readproctitle(8), fghack(8), pgrphack(8), tai64n(8), tai64nlocal(8), setuidgid(8), envuidgid(8), envdir(8), softlimit(8), setlock(8) http://cr.yp.to/daemontools.html multilog(8)
All times are GMT -4. The time now is 01:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy