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