Sponsored Content
Top Forums Shell Programming and Scripting Perl's buffered I/O is causing me to miss latest log file entries in log colorizer. How to fix? Post 302523813 by mirni on Friday 20th of May 2011 12:52:09 AM
Old 05-20-2011
You could look into sysopen and sysread. They are lower level I/O functions that work unbuffered (unlike <FILEHANDLE> operator).
Code:
sysopen(FILEHANDLE, $name, O_RDONLY) or die $!;

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

latest status of an field in a log file

Hi I have got a log file which is like: id status --------------------- 12345 status1.true 12345 status2.true 12345 status3.false 12345 status4.true 23452 status5.true 23452 status6.true 23452 status7.false 65243 ... (2 Replies)
Discussion started by: encrypted
2 Replies

2. UNIX for Dummies Questions & Answers

want to cat the latest log file created

everytime a new logfile get created at certain interval of time and i want a simple shell script program which cat the lastest log file when manually excuted (1 Reply)
Discussion started by: vkandati
1 Replies

3. Shell Programming and Scripting

search latest version of log file

Have checked the forums and couldnt locate help on this. I want to grep a log file for a pattern using a script - I need to grep the latest log file and not sure how I am able to ensure I am greping the latest log file. Here is sample of log files for yestersday and I effectively need to grep... (10 Replies)
Discussion started by: frustrated1
10 Replies

4. Shell Programming and Scripting

how can i pick the latest log file as per below

in the below .. i want to pick the latest logfile which is having JPS.PR inside.. that means i want particularly "spgport040408041223.log:@@@@@@@@ 04:13:09 Adding: JPS.PR." which is latest among these.. is it possible to compare the current time with logfile time ? reptm@xblr0758rop>... (4 Replies)
Discussion started by: mail2sant
4 Replies

5. Shell Programming and Scripting

Delete log file entries based on the Date/Timestamp within log file

If a log file is in the following format 28-Jul-10 ::: Log message 28-Jul-10 ::: Log message 29-Jul-10 ::: Log message 30-Jul-10 ::: Log message 31-Jul-10 ::: Log message 31-Jul-10 ::: Log message 1-Aug-10 ::: Log message 1-Aug-10 ::: Log message 2-Aug-10 ::: Log message 2-Aug-10 :::... (3 Replies)
Discussion started by: vikram3.r
3 Replies

6. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

7. Shell Programming and Scripting

Grep the Content of a LOG File which has latest Date and Time

Hi All, Need a small help. I have a log file which keeps updating for every Minute with multiple number of lines. I just want to grep few properties which has latest Date and Time to it. How do i do it? I wanted to grep a property by name "Reloading cache with a maximum of" from the... (4 Replies)
Discussion started by: nvindraneel
4 Replies

8. Shell Programming and Scripting

Parsing log file and print latest number in loop

Hello All, I have an awk script which parses my log file and prints number grepping from a specific line/pattern, now i have to come with a shell script to continue reading the log untill the job is completed, which i would know while reading session log untill process encounters a final... (1 Reply)
Discussion started by: Ariean
1 Replies

9. Shell Programming and Scripting

Selecting latest entry in the log file

Hi there I am trying to write a script where I will need to look for a specific word in the log file and I am aware this can be done by grep for example. As there will be multiple entries for this I want to grep the last one to enter the log... how would I go about this - would I have to use... (5 Replies)
Discussion started by: simpsa27
5 Replies

10. Shell Programming and Scripting

Monitor and capture the latest entry from the log file

Hi, I want to monitor a log file using tail -f command and search for a specific string on the most recent entry from the file. If the search string matches with the most recent or last line from the file, I want send an email to the people with the message. tail -f service.log|tail -n 1 ... (5 Replies)
Discussion started by: svajhala
5 Replies
Paranoid::Lockfile(3pm) 				User Contributed Perl Documentation				   Paranoid::Lockfile(3pm)

NAME
Paranoid::Lockfile - Paranoid Lockfile support VERSION
$Id: Lockfile.pm,v 0.65 2011/12/08 07:53:07 acorliss Exp $ SYNOPSIS
use Paranoid::Lockfile; $rv = plock($lockfile); $rv = punlock($lockfile); $rv = pcloseLockfile($lockfile); DESCRIPTION
This modules provides a relatively safe locking mechanism across multiple processes. This does not work over NFS or across remote systems, this is only intended for use on a single system at a time, and only on those that support flock. sysopen is used to avoid race conditions with multiple process attempting to create the same file simultaneously. SUBROUTINES
/METHODS plock $rv = plock($filename); This function attempts to safely create or open the lockfile. It uses sysopen with O_CREAT | O_EXCL to avoid race conditions with other processes. Returns a true if successful. Your can pass an optional second argument which would be a string of either 'write' or 'shared'. The default is 'write', which locks the file in exclusive write mode. You can pass an optional third argument which would be the lockfile filesystem permissions if the file is created. The default is 0600. NOTE: This function will block until the advisory lock is granted. punlock $rv = punlock($filename); This function removes any existing locks on the specified filename using flock. If no previous lock existed or it was successful it returns true. This does not, however, close the open filehandle to the lockfile. pcloseLockfile $rv = pcloseLockfile($filename); This function releases any existing locks and closes the open filehandle to the lockfile. Returns true if the file isn't currently open or the operation succeeds. DEPENDENCIES
o Fcntl o Paranoid o Paranoid::Debug BUGS AND LIMITATIONS
AUTHOR
Arthur Corliss (corliss@digitalmages.com) LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. (c) 2005, Arthur Corliss (corliss@digitalmages.com) perl v5.14.2 2011-12-08 Paranoid::Lockfile(3pm)
All times are GMT -4. The time now is 09:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy