Error Displaying last 10 minutes log with awk [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
This question already has an answer here:
Display lines in last 10 minutes with specific pattern in logs
3 answers
I am using below command to display log data for last 10 mins. It works fine if the month stays same however when month is changed it doesn't show any data.
awk -v d1="$D1" -v d2="$D2" '$0 > d1 && $0 < d2 || $0 ~ d2' /home/user.log
Works fine if,
D1="Aug 1 12:00:00"
D2="Aug 1 12:10:00"
But doesn't show any data if,
D1="Jul 31 11:55:00"
D2="Aug 1 00:05:00"
P.S I am using AIX
awk logs date aix data
marked as duplicate by msp9011, Rui F Ribeiro, Jeff Schaller, countermode, schily Aug 29 at 12:01
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
-1
down vote
favorite
This question already has an answer here:
Display lines in last 10 minutes with specific pattern in logs
3 answers
I am using below command to display log data for last 10 mins. It works fine if the month stays same however when month is changed it doesn't show any data.
awk -v d1="$D1" -v d2="$D2" '$0 > d1 && $0 < d2 || $0 ~ d2' /home/user.log
Works fine if,
D1="Aug 1 12:00:00"
D2="Aug 1 12:10:00"
But doesn't show any data if,
D1="Jul 31 11:55:00"
D2="Aug 1 00:05:00"
P.S I am using AIX
awk logs date aix data
marked as duplicate by msp9011, Rui F Ribeiro, Jeff Schaller, countermode, schily Aug 29 at 12:01
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
have you tried the answer by @JeffSchaller in unix.stackexchange.com/questions/464842/â¦
â msp9011
Aug 29 at 7:30
@SivaPrasath No bro, I found this awk single liner much easier. so i used this approach. But now its problematic.
â Hamas Rizwan
Aug 29 at 7:35
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
This question already has an answer here:
Display lines in last 10 minutes with specific pattern in logs
3 answers
I am using below command to display log data for last 10 mins. It works fine if the month stays same however when month is changed it doesn't show any data.
awk -v d1="$D1" -v d2="$D2" '$0 > d1 && $0 < d2 || $0 ~ d2' /home/user.log
Works fine if,
D1="Aug 1 12:00:00"
D2="Aug 1 12:10:00"
But doesn't show any data if,
D1="Jul 31 11:55:00"
D2="Aug 1 00:05:00"
P.S I am using AIX
awk logs date aix data
This question already has an answer here:
Display lines in last 10 minutes with specific pattern in logs
3 answers
I am using below command to display log data for last 10 mins. It works fine if the month stays same however when month is changed it doesn't show any data.
awk -v d1="$D1" -v d2="$D2" '$0 > d1 && $0 < d2 || $0 ~ d2' /home/user.log
Works fine if,
D1="Aug 1 12:00:00"
D2="Aug 1 12:10:00"
But doesn't show any data if,
D1="Jul 31 11:55:00"
D2="Aug 1 00:05:00"
P.S I am using AIX
This question already has an answer here:
Display lines in last 10 minutes with specific pattern in logs
3 answers
awk logs date aix data
awk logs date aix data
edited Aug 29 at 7:46
Rui F Ribeiro
36.8k1271117
36.8k1271117
asked Aug 29 at 7:10
Hamas Rizwan
454
454
marked as duplicate by msp9011, Rui F Ribeiro, Jeff Schaller, countermode, schily Aug 29 at 12:01
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by msp9011, Rui F Ribeiro, Jeff Schaller, countermode, schily Aug 29 at 12:01
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
have you tried the answer by @JeffSchaller in unix.stackexchange.com/questions/464842/â¦
â msp9011
Aug 29 at 7:30
@SivaPrasath No bro, I found this awk single liner much easier. so i used this approach. But now its problematic.
â Hamas Rizwan
Aug 29 at 7:35
add a comment |Â
have you tried the answer by @JeffSchaller in unix.stackexchange.com/questions/464842/â¦
â msp9011
Aug 29 at 7:30
@SivaPrasath No bro, I found this awk single liner much easier. so i used this approach. But now its problematic.
â Hamas Rizwan
Aug 29 at 7:35
have you tried the answer by @JeffSchaller in unix.stackexchange.com/questions/464842/â¦
â msp9011
Aug 29 at 7:30
have you tried the answer by @JeffSchaller in unix.stackexchange.com/questions/464842/â¦
â msp9011
Aug 29 at 7:30
@SivaPrasath No bro, I found this awk single liner much easier. so i used this approach. But now its problematic.
â Hamas Rizwan
Aug 29 at 7:35
@SivaPrasath No bro, I found this awk single liner much easier. so i used this approach. But now its problematic.
â Hamas Rizwan
Aug 29 at 7:35
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
I believe that's because it's really comparing the strings, not the dates. When the month changes it breaks the comparison.
Try formatting the date another way, maybe using epoch or numeric date format.
date -d "Jul 31 11:55:00" +%s
outputs 1533063300. Similarly,
date -d "Aug 1 00:05:00" +%s
outputs 1533107100.
Should be an easy comparison from there.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I believe that's because it's really comparing the strings, not the dates. When the month changes it breaks the comparison.
Try formatting the date another way, maybe using epoch or numeric date format.
date -d "Jul 31 11:55:00" +%s
outputs 1533063300. Similarly,
date -d "Aug 1 00:05:00" +%s
outputs 1533107100.
Should be an easy comparison from there.
add a comment |Â
up vote
0
down vote
I believe that's because it's really comparing the strings, not the dates. When the month changes it breaks the comparison.
Try formatting the date another way, maybe using epoch or numeric date format.
date -d "Jul 31 11:55:00" +%s
outputs 1533063300. Similarly,
date -d "Aug 1 00:05:00" +%s
outputs 1533107100.
Should be an easy comparison from there.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I believe that's because it's really comparing the strings, not the dates. When the month changes it breaks the comparison.
Try formatting the date another way, maybe using epoch or numeric date format.
date -d "Jul 31 11:55:00" +%s
outputs 1533063300. Similarly,
date -d "Aug 1 00:05:00" +%s
outputs 1533107100.
Should be an easy comparison from there.
I believe that's because it's really comparing the strings, not the dates. When the month changes it breaks the comparison.
Try formatting the date another way, maybe using epoch or numeric date format.
date -d "Jul 31 11:55:00" +%s
outputs 1533063300. Similarly,
date -d "Aug 1 00:05:00" +%s
outputs 1533107100.
Should be an easy comparison from there.
answered Aug 29 at 7:29
kevlinux
741
741
add a comment |Â
add a comment |Â
have you tried the answer by @JeffSchaller in unix.stackexchange.com/questions/464842/â¦
â msp9011
Aug 29 at 7:30
@SivaPrasath No bro, I found this awk single liner much easier. so i used this approach. But now its problematic.
â Hamas Rizwan
Aug 29 at 7:35