Last login with year


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Last login with year
# 8  
Old 01-27-2012
Thanks to all who replied.

Using wtmpx takes a lot of time for a single user.

I use the command

Code:
cat /var/adm/wtmpx | /usr/lib/acct/fwtmp| grep <user-id> | tail -1

I want to generate a report of all the users in the system with their last login date. The report will take hours. Any other solution?

Last edited by methyl; 01-27-2012 at 06:59 PM.. Reason: please use code tags
# 9  
Old 01-27-2012
Can you give us some figures related to the scale of your problem?

How many users in /etc/passwd ? Or are you also interested in deleted users?
How many day-to-day users?
How big is this wtmpx file ? Size unformatted and number of lines formatted?
How old is this wtmpx file? (Look at the first few records with fwtmp).
How powerful is the computer?

My usual approach is to break the wtmpx file into separate years and then use "last -f filename" in descending year order until we find the real last login. Obviously the day-today active users will be in this year's file by now. The "last" program itself reads wtmpx files backwards which is why it is so fast for active users.
We would use the "-n 1" parameter to "last" because we are only interested in the last login (this saves a lot of processing).

As your project design evolves, will you be running this report regularly? If so, it would be a good idea to consider starting a new wtmpx file regularly (and keeping the history if you need it) or even using a simpler system of recording the last login in the user's home directory.
I prefer the system of recording the last login in the user's home directory and then locking the account after 3 months non-use - or immediately if the user leaves the company. Unless your system allows significant disc space usage in user home directories there is no harm in just locking the account rather than deleting it. That way you will never get two different people with the same login account name and simple mistakes like Maternity Leave are easy to fix.

Last edited by methyl; 01-27-2012 at 06:56 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Can adding to a new group be effective in current login environment without re-login?

Hey folks, When a user is added to a new group, the user has to be log out and log in again to make the new group effective. Is there any system command or technique to refresh user group ID update without re-login? I am not talking about to use "login" or "su -l" commands which can only make... (2 Replies)
Discussion started by: hce
2 Replies

2. AIX

How to find the year in last login details

Hi Friends I have a query. we had a requirement to see the last login details of our users so I ran the command last <username> and the output i get is: wtmp begins Apr 17 21:48 Now I need to know couple of things: 1. How can I see the year this log is being read from wtmp file 2. Is... (4 Replies)
Discussion started by: nathandrake13
4 Replies

3. Solaris

error message rmclomv ... SC Login Failure for user Please login:

Hello World ~ HW : SUN Fire V240 OS : Solaris 8 Error message prompts 'rmclomv ... SC login failure ...' on terminal. and Error Message prompts continually 'SC Login Failure for user Please login:' on Single Mode(init S) The System is in normal operation, though In case of rain, Can... (1 Reply)
Discussion started by: lifegeek
1 Replies

4. Shell Programming and Scripting

Need "year" value of user's last login

Hello, We have a requirement of finding which users logged into a UNIX (Solaris) box and how many times they logged in so far and their last login. I used "last" command in my script and got everything fine but not able to capture the "year" of date/time of the users' login. Looks like "last"... (2 Replies)
Discussion started by: prvnrk
2 Replies

5. Solaris

How to : Find last login year in solaris ?

Thanks AVKlinux (10 Replies)
Discussion started by: avklinux
10 Replies

6. HP-UX

How to : Find last login year in HPUX ?

Thanks AVKlinux (4 Replies)
Discussion started by: avklinux
4 Replies

7. Shell Programming and Scripting

How to : Find last login year ?

Friends , With "last root | head -1 " command , we can find the last loging date and month . But i want to find last login year. Help me if u have any idea regarding this issue. Thanks AVklinux (3 Replies)
Discussion started by: avklinux
3 Replies

8. Cybersecurity

APACHE: Tie in Web Page login with server login

Hello, I have created a web page on a server using apache and added .htaccess and .htpasswd in the folder for authentification. I was wondering if there was anyway to tie-in the login for this page with the login used to logon to the server. i.e. the same login info. is used for both, when... (1 Reply)
Discussion started by: WhotheWhat
1 Replies

9. Web Development

APACHE: Tie in Web Page login with server login

Hello, I have created a web page on a server using apache and added .htaccess and .htpasswd in the folder for authentification. I was wondering if there was anyway to tie-in the login for this page with the login used to logon to the server. i.e. the same login info. is used for both,... (2 Replies)
Discussion started by: WhotheWhat
2 Replies
Login or Register to Ask a Question