Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: show only 30 minutes of log file

  1. #21
    Join Date
    Jul 2010
    Beans
    85

    Re: show only 30 minutes of log file

    Can you paste the code, so i can check at my local.

  2. #22
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: show only 30 minutes of log file

    The code is above in #13, you can add and remove extra print statements as you need to help with debugging. That is one method I often use.

  3. #23
    Join Date
    Jul 2010
    Beans
    85

    Re: show only 30 minutes of log file

    But text searching part [prod: pro: ] is not there? Can you please put that.

  4. #24
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: show only 30 minutes of log file

    Or are you wanting the script to change its output when encountering that string?

  5. #25
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: show only 30 minutes of log file

    Quote Originally Posted by learnbash View Post
    But text searching part [prod: pro: ] is not there? Can you please put that.
    Can you explain a little more about what is supposed to happen when that line is encountered? Is it supposed to find log entries less than 30 minutes old and print them only if they come after the line containing "prodro" ?

  6. #26
    Join Date
    Jul 2010
    Beans
    85

    Re: show only 30 minutes of log file

    Actually When script run that first find last 30 minutes of log file, so for example it greps 200 lines which have last 30 minutes of log. After that i wants to search "prod: pro:" in 200 lines, let suppose that text exist in 10 lines so only show those 10 lines discard 190 lines.

  7. #27
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: show only 30 minutes of log file

    Would it work to pipe the output through grep then?

    Code:
    ./last30minoflogs.pl /var/log/syslog | grep "prod: pro:"

  8. #28
    Join Date
    Jul 2010
    Beans
    85

    Re: show only 30 minutes of log file

    Yes Thanks so much, it is working you are cool. You are guru in perl, can you please suggest me so i can write perl scripts.

  9. #29
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: show only 30 minutes of log file

    Perl is fun and very, very useful for running a system. I picked up just the basics some years ago with books using it at work, but it should be easy to pick up from a lot of sources.

    If your college library has the book "Programming Perl" aka the Camel Book or the book "Learning Perl", that will help.

    There are online sources. "Beginning Perl" is online free: http://www.perl.org/books/beginning-perl/ and then there are some tutorials : http://learn.perl.org/tutorials/

    But above all, be comfortable looking up stuff in "man perlfunc" and the other builtin man pages. See "man perl" for the full list, divided by subject.

  10. #30
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    cpan

    By the way, the module Date::Calc is from the archive CPAN which has many thousands of modules. If there is a function or activity you want, there is probably a module for it. A good portion of the CPAN modules are already available in Ubuntu via the repositories, so you can add them using the package manager.

Page 3 of 4 FirstFirst 1234 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
  •