home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.aix
- Path: sparky!uunet!utcsri!geac!torag!jrh!jrh
- From: jrh@jrh.uucp (James R. Hamilton)
- Subject: Re: PC shutdown-RISC Logoff
- Message-ID: <1992Nov08.204045.120212@jrh.uucp>
- Fcc: outbox
- Organization: private system, Toronto, Ontario
- References: <16897B98D.CRAWFD@lexmark.com>
- Date: Sun, 08 Nov 1992 20:40:45 GMT
- Lines: 75
-
- In article <16897B98D.CRAWFD@lexmark.com> CRAWFD@lexmark.com writes:
- >We have several users accessing an application running on the RISC/6000 from
- >their pc running different X-Windows emulators. The problem is these users
- >often shutdown their pc without logging off the RISC/6000. Any processes
- >they we're running remain "active". Is there any way to automatically log
- >the user off the system when his/her pc is shutdown?? Or what would be
- >the preferred method of killing inactive processes?? Is there any process
- >that can be started to run in the background to check for inactive processes??
- >
- On a previous release of the O/S that I'm using SIGTERM wasn't sent to
- all process owned by a user when they hung up their telephone lines
- rather than logging off correctly. To work around this problem I wrote
- the following program that I ran once every 5 min from Cron. It checks
- for an idle port. If the user does nothing for an extended (user
- changeable option) then they will forced off.
-
- You might be able to use this or a derivitave of it to solve your problem.
-
- --jrh
-
-
- #!/bin/ksh
- #----------------------------------------------------------------------
- #
- # FILE: inactive
- # Author: James R. Hamilton
- # Date: 92.01.18 @ 22:13:21
- #
- #----------------------------------------------------------------------
-
- Usage="${0##*/}: USAGE ${0##*/} [-t port] [-d delay]"
- Port="tty0"
- Delay="10" #must not exceed 59
- set -- $(getopt "t:d:" $*)
- if [ $? != 0 ] ; then
- print "${0##*/}: Error in command line arguments"
- print "${0##*/}: $Usage"
- exit -1
- fi
- while [ "$1" != "--" ] ; do
- case $1 in
- -d)
- shift
- Delay="$1"
- ;;
- -t)
- shift
- Port="$1"
- ;;
- esac
- shift
- done
- who -u | while read Line ; do
- set -- $Line
- if [ "$2" = "$Port" ] ; then
- Time=$(print "$Line"| cut -c38-42)
- Hours=${Time%%:*}
- Minutes=${Time##*:}
- [ "$Minutes" = "" ] && Minutes=0
- [ "$Hours" = "" ] && Hours=0
- if [ "$Hours" -gt 0 ] || [ "$Minutes" -gt "$Delay" ] ; then
- print "$Port idle for $Hours:$Minutes ... executing kill -1 $7"
- kill -1 "$7"
- fi
- exit 0
- fi
- done
-
- #
- #-----------------------------> End of File <--------------------------
- --
-
- James R. Hamilton inet: jrh@jrh.gts.org
- telephone: +1 416 493 4162 uunet: ...!uunet!jrh!jrh
- Toronto, Canada work: jrh@torolab6.vnet.ibm.com
-