Ok, this is an offshoot of the other "Script Priority" topic I started
earlier today.
What I'd like to do is calculate what user has been logged into the
computer the longest. Not the last, most recent user. So far I have a
PHP script that processes the 'last' output and calculates the session
times, sorts it and gets the top user. From there, I do an LDAP lookup
to get the real user name, but that's already in Bash/sh. I'd have done
this all in Bash to start with but I'm more familiar with PHP.
So, to start out, I can get the data needed by calling this command. I'm
sure you understand this one, but just in case. "Last" is getting a list
of all computer/user sessions. "Grep" is getting just the
console/desktop sessions. And finally, "awk" is getting just the
columns/fields that I need.
last | grep console | awk '{print $1 " " $NF}'
