pattamuthuaj has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

A number of scripts (process) are running in our server (HP-Unix). Everyone creates the log file. I need to list all the log files that are currently being updated

Is there any other way to list the log files that are currently updated apart from based on the modified time?

Thanks,

Patta

Replies are listed 'Best First'.
Re: List all open log files
by varian (Chaplain) on Mar 31, 2007 at 06:27 UTC
    You could write a small Perl script to capture the output of the Unix command lsof for this purpose, it shows all files on the system that are in use by processes. You will need root privs to use it and select the type of logfiles you're interested in.
    lsof has a lot of options to track file size changes etc.
      You will need root privs to use it
      I don't know about HP-UX, but on Linux the user privileges of the process which is writing the logs will suffice.

      Thanks varian.

      I dont have the roor privilege

      Could I know the logic of the lsof command please?

      Regards,

      Patta

        Generally speaking lsof consults the 'files' in the /proc directory, hence realtime kernel memory structures. Refer to the manual pages (man lsof) for more details.

        If you do not have root privs then the lsof command will only show open files for processes that you own so not sure if that would do you much good?