Notifications
Clear all

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


amrit_3327
(@amrit_3327)
Trusted Member
Joined: 2 years ago
Posts: 65
Topic starter  

Command to extract logs from last one hour .


Quote
Topic Tags
amrit_3327
(@amrit_3327)
Trusted Member
Joined: 2 years ago
Posts: 65
Topic starter  
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: