ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/ihost-perl/ihostchk.sh
Revision: 1.3
Committed: Tue Nov 20 13:05:08 2001 UTC (22 years, 10 months ago) by tdb
Content type: application/x-sh
Branch: MAIN
Changes since 1.2: +3 -2 lines
Log Message:
Modified to know about new PID file location.

File Contents

# User Rev Content
1 tdb 1.1 #!/bin/sh
2     #
3     # Script to check that ihost is still running, and restart if necessary.
4     #
5     # You probably want to add this to a cronjob, say every 10 minutes:
6     # 0,10,20,30,40,50 * * * * /path/to/ihostchk.sh
7     # And if you find yourself getting e-mails, use the following instead:
8     # 0,10,20,30,40,50 * * * * /path/to/ihostchk.sh >/dev/null 2>&1
9     # NOTE: e-mails should only be sent if an error occurs, so the former is
10     # the best choice for a cronjob.
11     #
12 tdb 1.3 # $Id: ihostchk.sh,v 1.2 2001/03/12 23:51:15 tdb1 Exp $
13 tdb 1.1 #
14    
15     # CHANGE this to the directory of the ihost.pl script
16     ihostdir="/home/cut/tdb1/cvs/source/host/ihost"
17    
18     # CHANGE these to represent your filtermanager details
19     fmhost="raptor.ukc.ac.uk"
20     fmport="4567"
21    
22 tdb 1.2 # CHANGE this to point to the PID file
23 tdb 1.3 piddir=${HOME:-/var/tmp}
24     pidfile="$piddir/.ihost.pid"
25 tdb 1.1
26     ###### You probably don't need to change anything below here ######
27    
28     ihost="ihost.pl"
29    
30     cd $ihostdir
31    
32     # is there a pid file?
33     if test -r $pidfile
34     then
35     # there is a pid file, check to see if it's current
36     ihostpid=`cat $pidfile`
37     if `kill -CHLD $ihostpid >/dev/null 2>&1`
38     then
39     # it's still alive, lets leave it be
40     exit 0
41     fi
42     # old pid file found
43     echo ""
44     echo "Stale $pidfile file, removing..."
45     rm -f $pidfile
46     fi
47    
48     # if we got here, we're clear to restart ihost
49     echo ""
50     echo "ihost is not running, starting up..."
51     echo ""
52     ./$ihost $fmhost $fmport &
53     exit 0
54    
55     # finished