Date: Sun, 26 Aug 2001 01:30:49 -0400 From: luomat <luomat@peak.org> To: Chris Collins <collins@bsduser.ca> Cc: questions@FreeBSD.ORG Subject: Re: logging out a ghost user Message-ID: <17546367653.20010826013049@peak.org> In-Reply-To: <20010826002259.W451-100000@bsduser.ca> References: <20010826002259.W451-100000@bsduser.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
Sunday, August 26, 2001, 12:30:36 AM, Chris Collins wrote: Chris Collins> Sometimes I will ssh to my BSD machine from work but as expected my Chris Collins> windows machine at work dies and needs a reboot. I then log back into my Chris Collins> machine and find that I am still logged in. How do I disconnect or logout Chris Collins> that session that I did not disconnect from properly before? Hello Chris, I wrote this little shell script to display the PIDs of any processes which are running on a different TTY. It was written on a Linux box, not a FBSD one, so make sure that your 'who am i' command shows the TTY in the 2nd field, and that your 'ps -x' shows the PID in field 1. Save this script to a file like "idlepids.sh" and then do 'chmod 755 idlepids.sh' Then you can try kill -HUP `idlepids.sh` and if that doesn't work, try another kill signal, saving -9 to a last resort. Use at your own risk, of course. #!/bin/sh # Put your $PATH declaration here TTY=`who am i|awk '{print $2}'` # the next line should be all one line, no wrapping PIDS=`ps -x | egrep -v "${TTY}| STAT " | awk '{print $1}' |tr -s '\012' ' '` # a more robust and error-proof script might do something # here if "$PIDS" = "" but I trust the user to know what s/he is doing echo "${PIDS}" # exit 0 # That is the end of the script. HTH. TjL -- mailto:luomat@peak.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?17546367653.20010826013049>