Linux filters out logs between time periods

Source: Internet
Author: User

Such as: Filter out the secure log from August 30 22 o'clock to August 31 8 o'clock

Log format:

03:00:01 localhost crond[21772]: pam_limits (crond:session): Unknown limit type ' proc ' to 03:01:01 localhost cron D[21775]: Pam_limits (crond:session): Unknown limit type ' proc ' to 03:01:01 localhost crond[21775]: pam_limits (crond: session): Unknown limit type ' proc ' 03:30:01 localhost crond[21828]: pam_limits (crond:session): Unknown limit type ' Proc


    1. Using grep filtering

# Cat/var/log/secure | Grep-e "(30 22| 31 08) "This section only filters out the 30 22| 31 82 Days of

2. Using SED filtering

# sed-n '/aug 22:00:01/,/aug 08:30:01/p '/var/log/secure


This article is from the "willing to share with you" blog, please be sure to keep this source http://pengjc.blog.51cto.com/9255463/1844601

Linux filters out logs between time periods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.