|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Does anyone know how to get the last login timestamp for all the users who have used the system. I use logins -utx but it dosent give the last logins of the users. Can anyone help? Thx in adv.
|
|
#2
|
|||
|
|||
|
Basically i have a list of users already sorted in a file and i use the logins commands to get all the users that have logged in to the system and uniq the two lists to get the list of users who are not in the result of the logins command. Then i have to get the last login for this list of users and check whether it more than 90 days old...if yes...then i create another list with those users.
get users's login with last login --> grep users from another file --> compare both and create a new list with users not in the results of the first step --> get the last logins of the users in the new list --> if more than 90 days old then put that user in a new list. Any kind of help is greatly appreciated Thnx in adv. |
|
#3
|
||||
|
||||
|
finger
christo
__________________
. Spiration channels: Free scripts, programming tutorials and articles Dotcut alerts: Online Press cuttings / news alerts Clearprop: UK microlight school, wiltshire Uk dating: UK safe dating with Topdates About Christo . . |
|
#4
|
|||
|
|||
|
Quote:
try running: last to get a list of all logins in /var/adm/wtmpx (or wherever your installation of unix logs logins). to get a history of logins for a given user, run: last <user> if your host rotates the wtmpx file, you can query a given wtmpx file for a history of logins by running: last -f <path to wtmpx file> |
|
#5
|
||||
|
||||
|
why not just use finger to get the last login for the user...
eg$ finger chris Login: chris Name: chris lacy-hulbert Directory: /home/chris Shell: /bin/bash Office: 07751 615 397 On since Wed Apr 21 10:05 (BST) on pts/0 from wormwood.mailbox.net.uk No mail. No Plan. the matching is then a no-brainer in PERL. christo |
|
#6
|
|||
|
|||
|
I could do that but i have to compare two diff sets of user lists against each other...eg....File1(static list) and File2(Extracted list)....I have to compare file2 with file1 and extract a new list of users who dont exist in file to file3....then get their last logins and then remove those whose last login is more than 90 days old......does that seem logical?
thnx |
|
#7
|
|||
|
|||
|
Also if the user is not logged on, it does not give the last log in time.
|
|
#8
|
||||
|
||||
|
Quote:
yes it does: If never logged in: bash-2.05b# finger spiration Login: spiration Name: spiration Directory: /home/spiration Shell: /bin/bash Never logged in. No mail. No Plan. If not currently logged in: bash-2.05b# finger spira Login: spira Name: spira Directory: /home/spira Shell: /bin/bash Last login Mon May 5 10:21 2003 (BST) on pts/2 from 10.0.0.15 No mail. No Plan. what more could you need? christo |
|
#9
|
|||
|
|||
|
I am trying to figure this out as well.....although i dont need it to be as complicated. What i have right now is a file with all the usernames (from /etc/passwd) Now is there a way that i can make the finger commad run through that file and finger each username and send the results to a new file?
thanks, straylight |
|
#10
|
|||
|
|||
|
Quote:
You can write a scipt that will finger each user and send result to file. *note: If you go around fingering users, you might get a call from HR. ![]() |
|
#11
|
|||
|
|||
|
ha, yeah i am sure HR would get a real kick out of that! Anyway, i know you can write a script....i need some more detail than that though
![]() |
|
#12
|
||||
|
||||
|
Quote:
This sounds suspiciously like a homework question. You decide, my mind is already made up. Regards, jlk |
|
#13
|
|||
|
|||
|
My question is not a homework question.....i would just like to know how i can make the finger command finger every username in /etc/passwd. I am sure its not very hard, so if you have USEFUL information please bring it on
thanks, straylight |
|
#14
|
|||
|
|||
|
Code:
#!/usr/bin/perl
# assuming all names are on a seperate line
open (FILE, "/file_with_names") || die "$!";
while (<FILE>)
{
chomp;
push @users, $_;
}
close FILE;
foreach $name (@users)
{
`finger $name >> OutputFile`;
print "------------------" >> OutputFile; #seperator
}
This is untested perl, but should work. |
|
#15
|
|||
|
|||
|
fantastic, i wonder how many people insist to use the
wrong tool 4 the wrong job. really fantastic. btw faulkner try: Code:
s/\<\(sep\).\(rate\)\>/\1a\2/g
Straylight: the job is a 3-lines shell-script like: Code:
#!/bin/sh ( for name in `sed 's/:.*//' /etc/passwd` do finger $name done ) >output |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Getting Users' last login timestamp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|