Notifications
Clear all

How can we find maillogs from last one hour in Linux ?  

  RSS

amrit_3327
(@amrit_3327)
Trusted Member
Joined: 12 months ago
Posts: 59
03/08/2020 6:46 pm  

Command to extract logs from last one hour .


Quote
Topic Tags
amrit_3327
(@amrit_3327)
Trusted Member
Joined: 12 months ago
Posts: 59
03/08/2020 6:47 pm  
Use following command.
 
i=`date -d "1 hour ago"| awk '{print $2}'`; j=`date -d "1 hour ago"| awk '{print $3}'`;k=`date -d "1 hour ago"| awk '{print $4}'`; awk -v i="$i" -v j="$j" -v k="$k" '$1 == i && $2 == j && $3 > k {print $0}' maillog 

ReplyQuote
Share: