Link to home
Start Free TrialLog in
Avatar of assistunix
assistunixFlag for United States of America

asked on

Aix unix last login need assistance with writing script ksh

I need help writing a script to generate list of last login of all users in a server.
user's information is in /etc/passwd file and the command to list the last login of a user is "last username -n 1".
How can i put those two steps together in a script to get the output of last login of all users?
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Did you trY "last" without sspecifying a username?

wmp
Or if you want details for all users, in /etc/passwd file order, and not just those who've logged in try:

finger -sm root | egrep '^Login';(for user in `cat /etc/passwd | cut -f1,1 -d:  `; do finger -sm $user 2>/dev/null; done) | egrep -v '^Login'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of assistunix

ASKER

Thank you both.
arober11: your finger command syntax doesn't work right, give's an odd output. your last command only provides the listing of the user that i am logged in as, instead of all the users.

wmp: your command works like magic.