in reply to •Re: File tracking
in thread File tracking

Deeply appreciating your advise and sharing of wisdom I have to confess in meekness that my question apparently has not been put in a sufficiently stringent manner.
To make it clear now, the mentioned server is no Apache, and I am not in the position to change the logfile rotation procedure in this productive system :-(

I will pose some subquestions to clarify:

1) Is my implementation of "tail -f" neat enough? I think so.
2) Assuming that logfile rotation is working correctly, is the reopening of the current logfile done properly assuring no loss of data?
3) The real whole problem - how to manage the following possibilities:
a) rotated logfile with altered name may still be the active, no logfile with the original name present -> No problem (see inode comment in source)
b) at some indefinite time a new logfile with the original name becomes the active one -> Point 2

I ask for patience and balminess,
bearing in mind my own weakness.

-r

Replies are listed 'Best First'.
Re^3: File tracking
by ehdonhon (Curate) on Jul 06, 2002 at 18:57 UTC

    Is my implementation of "tail -f" neat enough? I think so.

    I don't know if sleep/poll cycles are the most efficient way of doing things here. You might want to try using select if you can.

    ... is the reopening of the current logfile done properly assuring no loss of data

    I'm not sure.. imagine this scenario:

    1. Your process scans the logs.
    2. Your process sleeps.
    3. While you are sleeping, the server outputs the bad error lines.
    4. Still while you are sleeping, the logs get rotated.
    5. When you wake up, you'll start processing the new file and never see the error lines.

      Thanks a lot for the first concrete steps towards a work around - work forever solution regarding lifetime of certain servers.

      I am aware of sleep being the possible "loss of data" - period, your scenario explains the problem excellently.
      Besides, I am stopping and re-starting the server because no other action (kill -HUP, native restart) solves the hang-up.
      What would be your approach (using select)?

      Be the munk that enlightens my soul and mind :-)

      -r