I can run the command last
(and last -i
) in a fraction of a second, but when I run last -d
, according to my tests, it takes a whopping 5 minutes and 22 seconds.
Just for reference, this is what adding the -d
flag does:
-d For non-local logins, Linux stores not only the host name of the remote host but its IP number as well. This option translates the IP number back into a hostname.
There is no indication in the man pages that it should take that much extra amount of time. As it says, Linux stores the IP already, so it shouldn't have to do any sort of slow reverse-lookup of the IP based on the hostname on the spot. In addition, it is slow even when it is "looking up" that the hostname value of :0
(a local login) should return the "IP address" value of 0.0.0.0
.
Is the -d
flag slow on all computers, or just mine? Could this indicate a corrupted file somewhere which may be inaccessible or difficult to read?
For reference, I am running 32-bit Ubuntu 13.10 (haven't upgraded yet).
-d
real, user, time (0m0.282s, 0m0.010s, 0m0.039s)
vs withoutreal, user, time (0m0.005s, 0m0.000s, 0m0.008s)
. So it's not affecting my pc. – polym Jun 24 '14 at 17:08last -i
take? – Ramesh Jun 24 '14 at 17:17last -i
takes0.007s
(virtually instant). – IQAndreas Jun 24 '14 at 17:19last -i
command and check if the host is reachable. I suspect it should be something related tonslookup
. – Ramesh Jun 24 '14 at 17:230.0.0.0
,127.0.0.1
, my home IP, and my work IP) are reachable viaping
(though my work IP takes about 47ms to reach). – IQAndreas Jun 24 '14 at 17:40last
command ( viaapt-get source sysvinit-utils
), write some test debug prints and look, where its taking forever? I guess it's taking forever at thegetnameinfo
call, but I might be wrong. – polym Jun 24 '14 at 17:44strace last -d
– Creek Jun 24 '14 at 18:40read(4,
part. If I wait, it continues after a few seconds and writes a bit of data, then hangs at aread(4
again. Let me know if you want the full output, instead of just up until the part where it hangs. – IQAndreas Jun 24 '14 at 18:45connect
to8.8.8.8
then/var/run/avahi-daemon/socket
thenwrite(4, "RESOLVE-ADDRESS 0.0.0.0\n", 24)
then the pause. Looks like @garethTheRed is on the right track, DNS resolution is getting stuck on 0.0.0.0 – Creek Jun 24 '14 at 19:08