/usr/bin/logontime is in hxtools 20170430-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #!/usr/bin/perl
#
# longontime - simple wtmp analyzer
# written by Jan Engelhardt, 2004-2007
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the WTF Public License version 2 or
# (at your option) any later version.
#
use Getopt::Long;
use strict;
my %Total;
my $ARG_time;
&Getopt::Long::Configure(qw(bundling));
&GetOptions("t" => \$ARG_time);
open(IN, "last -ax |");
while (defined(my $l = <IN>)) {
chomp $l;
my($user, $dur) = ($l =~ /^(\w+)\s+.+?\((.*?)\)/);
if ($user eq "") {
next;
}
my($h, $m) = split(/:/o, $dur);
$Total{$user} += $h * 60 + $m;
}
close IN;
if ($ARG_time) {
# Time sort
foreach my $u (sort { $Total{$b} <=> $Total{$a} } keys %Total) {
printf "%-8s: %3ud %2uh %2um (%5um)\n",
$u, int($Total{$u} / 1440), int($Total{$u} / 60 % 24),
int($Total{$u} % 60), $Total{$u};
}
} else {
# Alphabetical sort
foreach my $u (sort keys %Total) {
printf "%-8s: %3ud %2uh %2um (%5um)\n",
$u, int($Total{$u} / 86400),
int($Total{$u} / 60 % 86400), int($Total{$u} % 60),
$Total{$u};
}
}
|