
smart_amorist
New User
Jan 23, 2009, 4:55 AM
Post #1 of 2
(468 views)
|
|
Monitor Growing log Files for Exceptions
|
Can't Post
|
|
Hi All, I am writing a code to monitor running processes and their log files. Suppose I have two Processes: Process_1 and Process_2, logs are Log_1 and Log_2. Everyday process, run it write to same log file. I want to run the program in loop. First run it should point to end of current log. It will finish its first run after looking for Log_1 and Log_2. In next run it (say sleeping for 5 mins) shoud only read the newly added lines in log Log_1 , Log_2 and check for exceptions. It should not read the log file from beginning during each cycle. I am trying something as below: for (;;) { for ($curpos = tell(FILE); $_ = <FILE>; $curpos = tell(FILE)) { # search for some stuff and put it into files } sleep($for_a_while); seek(FILE, $curpos, 0); } But it is not working. I am new to perl so not able to find much. Please assist.
|