LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Administration (https://www.linuxquestions.org/questions/linux-newbie-8/administration-839292/)

legaboka 10-20-2010 09:45 AM

Administration
 
HI

How do we check if a particular user has logged off. I only know how to check if a user logged in either by using who, w or last but don'thave an idea of how to check if a user has logged off.

Any idea?

aizkorri 10-20-2010 10:36 AM

you can check doing:

last <username> and that will list all the sessions od that user.

hope that helps

Snark1994 10-20-2010 11:32 AM

I don't quite see what your problem is...
Code:

who -u | grep "user"
should tell you if a user is logged in or not - if it produces output, then that user is logged in. If there is no output, then that user isn't logged in.

Or am I misunderstanding you?

legaboka 10-21-2010 04:03 AM

Quote:

Originally Posted by Snark1994 (Post 4133711)
I don't quite see what your problem is...
Code:

who -u | grep "user"
should tell you if a user is logged in or not - if it produces output, then that user is logged in. If there is no output, then that user isn't logged in.

Or am I misunderstanding you?

What i mean is that, the script should detect if a certain user has logged off and also inform me which user logged off.

when using last to check those who logged in, it indicates that by a phrase "still logged in" and I want to know how i can see if one of the users who logged in has logged off/out.

Thanks

prayag_pjs 10-21-2010 04:21 AM

who -u |grep -i "user"> /dev/null
if [ $? -eq 0 ];
then
echo "User is Logged In";
else
{
echo "User Logged Off"
}
fi

Also note if user is never logged in then also it will say User logged off


All times are GMT -5. The time now is 10:06 AM.