LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   tail -f utilization (https://www.linuxquestions.org/questions/linux-general-1/tail-f-utilization-564362/)

jschiwal 06-26-2007 05:31 PM

Code:

schiwalj@FAR_ADSDT1 ~
$ cat testdata
Date: 6/26/07 1:33:14 PM
LogName: NAME1
Logtype: TYPE1
LogUser: USER1
LogClient: CLIENT1
LogServer: SERVER1
LogLife: LIFE1
LogContent: CONTENT1
--
Date: 6/26/07 1:33:15 PM
LogName: NAME2
Logtype: TYPE2
LogUser: USER2
LogClient: CLIENT2
LogServer: SERVER2
LogLife: LIFE2
LogContent: CONTENT2
--
Date: 6/26/07 1:33:16 PM
LogName: NAME3
Logtype: TYPE3
LogUser: USER3
LogClient: CLIENT3
LogServer: SERVER3
LogLife: LIFE3
LogContent: CONTENT3
--
schiwalj@FAR_ADSDT1 ~
$ cat td.sed
#n
/Date:/,/--/{
              /Date:/H
              /Logtype:/H
              /LogUser:/H
              /--/{ x
                    s/^--//
                    s/^\n//
                    s/\n/ - /gp
                  }
            }


schiwalj@FAR_ADSDT1 ~
$ sed -f td.sed testdata
Date: 6/26/07 1:33:14 PM - Logtype: TYPE1 - LogUser: USER1
Date: 6/26/07 1:33:15 PM - Logtype: TYPE2 - LogUser: USER2
Date: 6/26/07 1:33:16 PM - Logtype: TYPE3 - LogUser: USER3

I'd have to break out my sed & awk book to improve on this. When I tried the 'g' instead of the 'x' command, it didn't work right, so I needed to eliminate the '--' added back to the buffer.

mfran2002 06-27-2007 03:16 AM

good morning!

i tried your scripts and i've a question regarding 'Agrouf' suggestion:

my logfile is filled every minute (every minute the application takes data from db and fills logfile)
it seems that 'Agrouf' script works good only for the first filling, then it stops...

do you know why?

thanks.

Agrouf 06-28-2007 12:06 PM

I suspect it because of EOF.
It is probably because the program writing to the log files closes it every time it has written to it (every minutes that is).
It would be strange because I don't think that would stop tail.
Can you try tail with -F instead of -f please?

jlliagre 06-28-2007 12:35 PM

Quote:

Originally Posted by mfran2002
it seems that 'Agrouf' script works good only for the first filling, then it stops...

do you know why?

Can you post the real script you use ?

Also, I mentioned earlier you would have buffering issues. That may be the case here.


All times are GMT -5. The time now is 09:04 AM.