I need your help.


 
Thread Tools Search this Thread
Operating Systems Solaris I need your help.
# 8  
Old 09-07-2008
Sorry, if that was such a bad reply.

Truly, the problem in statement is "check for every 'n' units of time". If it has to be checked for 'n' units of time then for the each slice of time the file has to be definitely opened, parsed through, validated or checked against and then closed again.

This has to be definitely done by a process. Using crond for that is ruled out ( as said by you ). So, another process that does a minimal of crond ( a real minimal ) is needed.

Whats wrong with the suggestion I had posted ? For every 'n' units of time, the process is going to wake up and going to do its job; rest of the time it would be in sleep mode so its not blocking the run queue of the runnables nor using up a considerable time slice in doing not-so useful while (1) or something like that.

Any, event tracker or event notifier has to work with the resource ( open, read, close ) and then inform the process blocking on the event notifiers/trackers.

Or, did you mean something else ?

Experts here might post different and better solutions Smilie
# 9  
Old 09-07-2008
Quote:
we cant keep checking the file because this will take a lot of time....
Why this would take a lot of time ?
A slot in the process table and a SIGALRM call for every 'n' units of time.

Quote:
we need somekind of alert when it happens.
At the end, somebody has to alert that.
# 10  
Old 09-07-2008
If you grep the whole file every time, you will find previous occurrences. If it is a huge logfile, for example, grepping thru the whole thing could take long than five seconds. It sounds exactly like monitoring a log file to me. Again, this is why we have tail -f.

Do you have anyway to get the process to do a log rotate - like signalling the process with a SIGHUP? This would make a full file grep feasible.
# 11  
Old 09-07-2008
Quote:
Again, this is why we have tail -f
I was thinking in the following lines

- open the file only once
- sleep for 'n' units of time
- once process is awake, store the current file position
- reopen the file and position the file pointer to the value stored in previous step
- now validate, grep, processing etc
- sleep once again
- just loop through the above process
# 12  
Old 09-07-2008
Thank you both for your answers..

The problem is that Im not expert in UNIX... what I want is to trigger the script or alert or anything once the input file contains that patteren.. I dont want to make a cron job to check the file... I want this pattern to be like a trigger....

I know you are pulling out your hair by now Smilie ...

Thanks againnnnn
# 13  
Old 09-07-2008
Quote:
trigger the script or alert or anything
That again boils down to reading the file "to know whether the pattern has occurred or not" which has to be done by some process.

How would you expect to automatically be identified about a pattern in a file without actually reading that ? This is as good as - not reading the file and arriving at an answer - "no such pattern in the file".

Smilie
# 14  
Old 09-07-2008
Ya I know I have to read it ..... but I thought that maybe there is a proccess to get rid of reading the file, and use the patteren as trigger .... Smilie

Thanks a lot...

Smilie matrixmadhan & jim mcnamara Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question