Click to See Complete Forum and Search --> : permanently knowing who's on my system


spx2
12-26-2007, 04:42 AM
I needed to know who is on my machine permanently.
I wrote these ,and I got a window wich permanentlu shows who's
logged on the system.

spx2@firepower:~/server_scripts$ pwd
/home/spx2/server_scripts
spx2@firepower:~/server_scripts$ cat monitor_users_logged_in.pl
while(1){print `who`;sleep 1;system 'clear' }
spx2@firepower:~/server_scripts$ cat report_logged_users.sh
xterm -e sh -c "perl /home/spx2/server_scripts/monitor_users_logged_in.pl"
spx2@firepower:~/server_scripts$

happybunny
12-26-2007, 07:51 AM
why doesn't w or who or last do that for you?

spx2
12-26-2007, 08:03 AM
because who/w is for the current moment.
how about if you want to know every second who's logged ?
well,I don't know if this is very useful or uhm if there's something
that accomplishes this already..thought I should post it.

bwkaz
12-26-2007, 11:58 AM
while : ; do
who
sleep 1
clear
done will also work, and doesn't require Perl. But maybe requiring Perl isn't a big deal?

Actually, it might be nice if who or w or last had an option to say "run over and over, updating every X seconds", but in Unix-like OSes, it seems that an option like that is usually done by writing another program. For instance, ps has no way to run continuously; if you need that, you have to run top. (Maybe there's a similar utility for showing who's logged on? If there is, I don't know what it is.)

TheCatMan
07-04-2008, 12:09 PM
I know I'm a bit late but I recently stumbled on a third way to do it:

xterm -e 'watch -n 1 who'

bwkaz
07-05-2008, 05:54 PM
Yeah, I'm not sure why I didn't think of watch six months ago, but there you go. Good addition. :)