I've written a simple ksh script to list the last login for all the users on my systems. The problem is that it uses the last command and if the user hasn't logged in since the wtmp file was created I only get the following from last:
wtmp begins Feb 23 11:40
My script looks like this
for i in `lsuser -a ALL`
echo `last -1 $i` >> /tmp/lastloginnew.txt
I also found the following script here, on this forum, but it was from 2005 so I decided that it wasn't probably being monitored.
Both of these give me the same thing, just that the first redirects the output to a file that I can e-mail to other team members.
What I'm looking for is some way for the script to print the user name prior to running the last command so that each line will give me the user name the last command is running for. Any help would be greatly appreciated.