Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: tail all log

  1. #1
    Join Date
    Apr 2005
    Beans
    19

    tail all log

    I'm trying to make a tailer for all logfiles, but I cant seem to find a way to test if a file is a textfile.

    Code:
    FILES=$( ls /var/log/* )
    while true ; do
      for file in $FILES
      do
         if [ -N $file ] && [ -f $file ] && [ -r $file ] ; then
    	tailer=$( tail -n 1 $file )
    	if [ "$tmp" != "$tailer" ] ; then
    	   echo $tailer
    	   tmp=$tailer
    	fi
         fi
       done
    done
    exit 0
    Last edited by student; August 17th, 2005 at 07:04 PM.
    ..it's error's that produce intelligence..

  2. #2
    Join Date
    Nov 2004
    Beans
    2,614

    Re: tail all log

    I'm confused by what you want to do in the first place: why?

    And why bother checking? If the user is dumb enough to tail a file that might be binary, they deserve to get gibberish spewed on their screen.

  3. #3
    Join Date
    Apr 2005
    Beans
    19

    Re: tail all log

    Quote Originally Posted by LordHunter317
    I'm confused by what you want to do in the first place: why?

    And why bother checking? If the user is dumb enough to tail a file that might be binary, they deserve to get gibberish spewed on their screen.
    and the checking is done how ?
    ..it's error's that produce intelligence..

  4. #4
    Join Date
    Nov 2004
    Beans
    2,614

    Re: tail all log

    It isn't, that was my point. You should code in the names of the logfiles, or look them up from some source like /etc/syslog.conf (which will be hell to do in bash).

    Otherwise, you let the user provide the names, and if the file is binary, you just tail it. You assume the user knwos best.

    I still don't understand why you're doing this. If you want an agrregate log to tail, set one up in /etc/syslog.conf.

    What you're trying to do is bad, for a bunch of reasons.

  5. #5
    Join Date
    Apr 2005
    Beans
    19

    Re: tail all log

    just because I want to tail all the logs in /var/log/ even when suddonly one is added for some reason, and without checking files each loop.
    ..it's error's that produce intelligence..

  6. #6
    Join Date
    Nov 2004
    Beans
    2,614

    Re: tail all log

    But you don't want to do that. Logs won't show up often, and it's not a burden on the administrator to change the script when they have to change syslog.conf anyway.

    Why are you writing this application in the first place? What purpose does it serve? Moreover, what does it do beyond what syslogd already provides?

    You need to answer those questions first.

  7. #7
    Join Date
    Apr 2005
    Beans
    19

    Re: tail all log

    because this provides me with a little eterm at the bottom of my desktop,
    with all the logged events showing up. And I want it this way.
    screenshot
    ..it's error's that produce intelligence..

  8. #8
    Join Date
    Nov 2004
    Beans
    2,614

    Re: tail all log

    Quote Originally Posted by student
    because this provides me with a little eterm at the bottom of my desktop,
    with all the logged events showing up. And I want it this way.
    screenshot
    Then either setup a single log file to tail that has all the information you want loaded in, or setup a pipe to /dev/xconsole and tail that. The latter is probably preferrable.

    Doing what you want won't work: for starters, the odds of missing a message are quite high. Not to mention the terribly nasty system load.

  9. #9
    Join Date
    Apr 2005
    Beans
    19

    Re: tail all log

    Code:
    FILES=$( ls /var/log/*log  /var/log/messages /var/log/debug /var/log/aptitude )
    while true ; do
    for file in $FILES
    do
    	if [ -N $file ] && [ -f $file ] && [ -r $file ] ; then
    	  	tailer=$( tail -q -n 1 $file | tr −d "\"'" )
    	  	if [ "$tmp" != "$tailer" ] ; then
    			echo "$tailer"
    			echo
    			tmp=$tailer
    		fi
    	fi
    done
    sleep 1
    done
    exit 0
    I can live with my script here, this give's me a total system load at this moment of 2%
    ..it's error's that produce intelligence..

  10. #10
    Join Date
    Nov 2004
    Beans
    2,614

    Re: tail all log

    Too bad it's going to miss messages, on a fairly regular basis to boot if your system has regular load. And it's going to duplicate messages.

    Why are you so hellbent on using a script. Look up the documentation on syslog.conf. You can configure a custom log to give you exactly what you want, in a manner that's easy to provide to X.

    Hell, I'd even tell you how to do it if you'd tell me what you wanted. But I can't help you if you won't help me.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •