Thursday, March 12, 2020

When did each /var/log/messages file start logging ?

Getting an idea of when each /var/log/messages file, compressed or not, first started. Printing the first line of each file.

for logfile in /var/log/messages*
do  
   if [[ $logfile == *.bz2 ]]
   then 
      echo -ne "$logfile\t" 
      bzcat $logfile | head -1 
   else
      echo -ne "$logfile\t"
      cat $logfile | head -1
   fi
done

No comments: