timepattern
Oct. 25th, 2018 05:11 pmLive apps write logs. Usually they splurge a huge amount of repetitive meaningless noise: the same thing reported again and again. Fixing things in live apps means fishing in lots of logs among all the dross for a clue as to what went wrong.
One thing that makes this hard is that different logs don't agree about the format for time stamps. These are all the same:
You can use it like this:
"Search in all the logs for the messages with the right time pattern"
Windows users: install Cygwin
One thing that makes this hard is that different logs don't agree about the format for time stamps. These are all the same:
25-Oct-2018 16:45:00 2018-10-25 16:45:00 25/Oct/2018:16:45:00So if I think the problem was logged at 16:45 in one of the logs, how do I search? Say hello,
timepattern
#!/usr/bin/env bash year=$1 month=$2 day=$3 hour=$4 minute=$5 case ${month} in 1|01) mword=Jan ;; 2|02) mword=Feb ;; 3|03) mword=Mar ;; 4|04) mword=Apr ;; 5|05) mword=May ;; 6|06) mword=Jun ;; 7|07) mword=Jul ;; 8|08) mword=Aug ;; 9|09) mword=Sep ;; 10) mword=Oct ;; 11) mword=Nov ;; 12) mword=Dec ;; *) mword=zzz ;; esac echo "(${day}-${mword}-${year} |${year}-${month}-${day} |${day}/${mword}/${year}:)${hour}:${minute}:"
You can use it like this:
grep -Ea "$(timepattern 2018 10 25 16 45)" $(findallthelogs)
"Search in all the logs for the messages with the right time pattern"
Windows users: install Cygwin