Error Displaying last 10 minutes log with awk [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash 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










share|improve this 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














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










share|improve this 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












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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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










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.






share|improve this answer



























    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.






    share|improve this answer
























      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.






      share|improve this answer






















        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 29 at 7:29









        kevlinux

        741




        741












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay