'Check log file for error only for last 10 mins
I've a log file with below text,
[2022-05-05T22:25:58,523] Text/debug data
I want to fetch log data for errors in only last 10 mins to configure in cron. How to fetch the data only for last 10 mins.
Solution 1:[1]
d=$(date -d -10min '+[%Y-%m-%dT%H:%M:%S,000]')
awk -v "d=$d" '$1 >= d {p=1} p' logfile
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | dan |