Visit Our UNIX and Linux User Community


is there a command to see when the last time a user has been online if they arent?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers is there a command to see when the last time a user has been online if they arent?
# 8  
Old 01-17-2012
Ignoring current sessions, and just displaying last time user logged in:

Code:
last $1 | grep -v "still logged in" | head -1

In general this is better achieved by keeping records in the user's home directory. This is because many administrators maintain the "wtmp" file (used by "last") to conserve disc space ... and if they don't maintain the file a "last" command on a "wtmp" file which is more than a year old can be misleading.
# 9  
Old 01-17-2012
Better use
Code:
last -w

if you need the full user name.
# 10  
Old 01-17-2012
Quote:
pandeesh:
Better use
Code:
last -w

if you need the full user name.
What OS are you using, and what makes you believe you know better than methyl or myself? Not mentioning you are going off topic (read again the very first post!)...

-w is non UNIX standard... (nor did I find in standard linux, HP-UX, or open solaris, or MacOSX (up to 10.5.6)) so unless the thread owner states what OS he is using, the rules here is to stick to pure standard UNIX solutions, this is not the first time you go on and on on pointless argument so please stop unless you are sure to add a real plus here.

Last edited by vbe; 01-17-2012 at 06:22 PM.. Reason: typos
# 11  
Old 01-18-2012
in my ubuntu 11.10
Code:
last

doesn't return full user name and only
Code:
last -w

did.
Sorry!!
# 12  
Old 01-18-2012
Code:
 
last $1 | awk '!/still logged in/{print $1 "is not online and last logged in " $5 " " $6 " " $9" " $10;exit}'

 

Previous Thread | Next Thread
Test Your Knowledge in Computers #269
Difficulty: Easy
Apple merged with NeXT in 1997, and subsequently, Steve Jobs became Apple's CEO again.
True or False?

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

History of all the users in single file with command , date . time , ip and user

HTML Code: archive_history() { HISTORYOLD=${HISTFILE}.archive CURTIME=`date` CURTTY=`tty` IP=$(echo $SSH_CLIENT | awk '{print $1}') if ; then echo "#-${HOSTNAME}-- ${CURBASHDATE} - ${CURTIME} ($CURTTY) ${USER} ${IP}----" >> $HISTORYOLD history... (0 Replies)
Discussion started by: rehantayyab82
0 Replies

2. Shell Programming and Scripting

History of all the users in single file with command , date . time , ip and user

HTML Code archive_history() { HISTORYOLD=${HISTFILE}.archive CURTIME=`date` CURTTY=`tty` IP=$(echo $SSH_CLIENT | awk '{print $1}') if ; then echo "#-${HOSTNAME}-- ${CURBASHDATE} - ${CURTIME} ($CURTTY) ${USER} ${IP}----" >> $HISTORYOLD history... (2 Replies)
Discussion started by: rehantayyab82
2 Replies

3. UNIX for Advanced & Expert Users

time duration of being online of a particular user given the user name

in a multi user system of 3 users X,Y,Z, if i know that X is presently online, is it possible to determine for how long has he been online? i mean the time duration (3 Replies)
Discussion started by: arindamlive
3 Replies

4. Shell Programming and Scripting

Online user list script

I decided to delete the first post since it was againt the forum rules (4 Replies)
Discussion started by: Necrologist
4 Replies

5. Programming

checking the heartbeat of the online user

hello, Can anyone please tell me how can i check the availability of the online user in a client-server environtment. This is for a program where lakhs of client are connected to the server and the server has to check the availability of the every client in every minute. So polling every client... (0 Replies)
Discussion started by: shushilmore
0 Replies

Featured Tech Videos