I've currently got a bash script that parses /var/log/mail.log to determine the last login time/date of a imap user. I've determined Perl is going to be a lot more efficient and quicker for this task, especially as the logs grow.
Given the following example /var/log/mail.log file:
Jul 5 06:57:54 mail-04 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 06:59:54 mail-04 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 06:59:59 mail-04 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 07:01:54 mail-04 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 07:01:59 mail-04 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
What is the most efficient way in Perl to print the last login time of each unique user? E.g. the expected output should be:
[email protected] last imap-login: Jul 5 07:01:54
[email protected] last imap-login: Jul 5 07:01:59