home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / aix / 11394 < prev    next >
Encoding:
Text File  |  1992-11-09  |  2.8 KB  |  87 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!utcsri!geac!torag!jrh!jrh
  3. From: jrh@jrh.uucp (James R. Hamilton)
  4. Subject: Re: PC shutdown-RISC Logoff
  5. Message-ID: <1992Nov08.204045.120212@jrh.uucp>
  6. Fcc: outbox
  7. Organization: private system, Toronto, Ontario
  8. References: <16897B98D.CRAWFD@lexmark.com>
  9. Date: Sun, 08 Nov 1992 20:40:45 GMT
  10. Lines: 75
  11.  
  12. In article <16897B98D.CRAWFD@lexmark.com> CRAWFD@lexmark.com writes:
  13. >We have several users accessing an application running on the RISC/6000 from
  14. >their pc running different X-Windows emulators.  The problem is these users
  15. >often shutdown their pc without logging off the RISC/6000.  Any processes
  16. >they we're running remain "active".  Is there any way to automatically log
  17. >the user off the system when his/her pc is shutdown??  Or what would be
  18. >the preferred method of killing inactive processes??  Is there any process
  19. >that can be started to run in the background to check for inactive processes??
  20.     On a previous release of the O/S that I'm using SIGTERM wasn't sent to
  21.     all process owned by a user when they hung up their telephone lines 
  22.     rather than logging off correctly.  To work around this problem I wrote 
  23.     the following program that I ran once every 5 min from Cron.  It checks 
  24.     for an idle port.  If the user does nothing for an extended (user 
  25.     changeable option) then they will forced off.  
  26.  
  27.     You might be able to use this or a derivitave of it to solve your problem.
  28.  
  29.                                 --jrh
  30.  
  31.  
  32. #!/bin/ksh
  33. #----------------------------------------------------------------------
  34. #
  35. #            FILE:    inactive
  36. #            Author:    James R. Hamilton
  37. #            Date:    92.01.18 @ 22:13:21
  38. #
  39. #----------------------------------------------------------------------
  40.  
  41.     Usage="${0##*/}: USAGE ${0##*/} [-t port] [-d delay]"
  42.     Port="tty0"
  43.     Delay="10"          #must not exceed 59
  44.     set -- $(getopt "t:d:" $*)
  45.     if [ $? != 0 ] ; then
  46.     print "${0##*/}: Error in command line arguments"
  47.     print "${0##*/}: $Usage"
  48.     exit -1
  49.     fi
  50.     while [ "$1" != "--" ] ; do
  51.     case $1 in
  52.         -d)
  53.         shift
  54.         Delay="$1"
  55.         ;;
  56.         -t)
  57.         shift
  58.         Port="$1"
  59.         ;;
  60.     esac
  61.     shift
  62.     done
  63.     who -u | while read Line ; do
  64.     set -- $Line
  65.      if [ "$2" = "$Port" ] ; then
  66.             Time=$(print "$Line"| cut -c38-42)
  67.         Hours=${Time%%:*}
  68.         Minutes=${Time##*:}
  69.         [ "$Minutes" = "" ] && Minutes=0
  70.         [ "$Hours" = "" ] && Hours=0
  71.         if [ "$Hours" -gt 0 ] || [ "$Minutes" -gt "$Delay" ] ; then
  72.         print "$Port idle for $Hours:$Minutes ... executing kill -1 $7"
  73.         kill -1 "$7"
  74.         fi
  75.         exit 0
  76.     fi
  77.     done
  78.  
  79. #
  80. #-----------------------------> End of File <--------------------------
  81. -- 
  82.  
  83. James R. Hamilton                              inet: jrh@jrh.gts.org
  84. telephone: +1 416 493 4162                     uunet: ...!uunet!jrh!jrh
  85. Toronto, Canada                                work: jrh@torolab6.vnet.ibm.com
  86.