home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / xenix / sco / 2793 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.6 KB  |  42 lines

  1. Newsgroups: comp.unix.xenix.sco
  2. Path: sparky!uunet!spool.mu.edu!cserver!edsi!chuck
  3. From: chuck@edsi.plexus.COM (Chuck Tomasi)
  4. Subject: Re: Keep-alive watchdog for shell process
  5. Organization: Enterprise Data Systems Incorporated, Appleton WI
  6. Date: Wed, 02 Sep 1992 11:39:15 GMT
  7. Message-ID: <1992Sep02.113915.13633@edsi.plexus.COM>
  8. References: <64683@cup.portal.com>
  9. Lines: 31
  10.  
  11. compata@cup.portal.com (David H Close) writes:
  12.  
  13. :)Does anyone know of a way to make a shell process dependent upon the
  14. :)periodic receipt of a "keep-alive" signal?  Of course, I mean through the
  15. :)use of the standard set of shell commands and system utilities.  That is,
  16. :)without programming except in sh, is there a way to make a shell process
  17. :)die if it doesn't receive some signal at regular intervals?
  18.  
  19. How about reversing the logic and telling it to die if it DOES see the
  20. signal?  You could then use something like trap (a /bin/sh and /bin/ksh
  21. builtin) to do a clean exit when one or more signals is encountered.
  22.  
  23. A simple example might be:
  24.  
  25. #!/bin/sh
  26. echo "process started `date`">>/usr/adm/some.log
  27. trap "echo 'process killed `date`'>>/usr/adm/some.log;exit 0" 15
  28. while `true`
  29. do
  30.     sleep 60
  31.     # do something here
  32. done
  33.  
  34. This was written from the cuff so I apologize for any slight errors.
  35. The jist of it is to die and echo something to the log file when signal
  36. 15 is received, otherwise just keep running ad infinitum.
  37. -- 
  38. Chuck Tomasi             |     "It's my job to help
  39. chuck@edsi.plexus.COM    |      but I don't have to like it."
  40. spool!cserver!edsi!chuck |                    -Dr. Crusher, "I, Borg"
  41. ------<Enterprise Data Systems Incorporated, Appleton Wisconsin>------
  42.