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?
# 1  
Old 01-16-2012
is there a command to see when the last time a user has been online if they arent?

When I use who it shows who is online and from what time they logged in but is there a way I can see the last time someone was logged on if they aren't online? Is it with the who command?
thx
# 2  
Old 01-16-2012
Yes last command, look at the man pages!
This User Gave Thanks to vbe For This Post:
# 3  
Old 01-16-2012
if you want to filter out the last time alone then use:
Code:
last |head -1

Code:
pandeeswaran@ubuntu:~$ last |head -1
pandeesw pts/0        :0               Mon Jan 16 13:13   still logged in

This User Gave Thanks to pandeesh For This Post:
# 4  
Old 01-16-2012
Quote:
Originally Posted by pandeesh
if you want to filter out the last time alone then use:
Code:
last |head -1

Code:
pandeeswaran@ubuntu:~$ last |head -1
pandeesw pts/0        :0               Mon Jan 16 13:13   still logged in

thank you

im writing a script that displays the last time the user has been on and a quick question here

Currently it displays the last time the user has been on but multiple times, will using head -1 limit it to one? I have tried head -1 and it returns nothing in the script

Code:
 last | grep $1 | awk '{print $1 "is not online and last logged in" $5 "" $6 "" $9"" $10}'

the $1 is the input from the user
# 5  
Old 01-16-2012
Try this:
Code:
last $1 |head -1| awk '{print $1 "is not online and last logged in" $5 "" $6 "" $9"" $10}'

# 6  
Old 01-16-2012
Why use grep user when you can give the user name as argument to last?
# 7  
Old 01-16-2012
If you really wants to use grep , then try this:
Code:
last -w|grep $1

 
Login or Register to Ask a Question

Previous Thread | Next Thread

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
Login or Register to Ask a Question