Advertisement
jpontius

perl-wtmp-script

Aug 7th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.28 KB | None | 0 0
  1. #!/usr/bin/perl
  2. open LAST, "last -f /var/log/wtmp.1 |";
  3. while (<LAST>) {
  4.     if (($name,$days,$hours,$mins) = /^(\w+).+\((?:(\d+)\+)?(\d+):(\d+)/) {
  5.         $TIMES{$name} += 1440 * $days + 60 * $hours + $mins;
  6.     }
  7. }
  8. foreach (sort keys %TIMES) {
  9.     print "$_ $TIMES{$_}\n";
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement