-
Notifications
You must be signed in to change notification settings - Fork 14
/
checkmech
executable file
·54 lines (44 loc) · 1.07 KB
/
checkmech
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/sh
#--------------------------------------------------
# Cron script for EnergyMech 3.0
#--------------------------------------------------
#
# you can add this to your crontab (crontab -e) as
# something like:
#
# 0,10,20,30,40,50 * * * * /path/to/checkmech
#
# this will check the mech every 10 minutes.
#
#--------------------------------------------------
echo "You havent edited checkmech yet!!"
exit 0
# CHANGE THIS LINE!!
cd /path/to/energymech/directory
# name of executable
RUN=./mech
# options passed to the energymech
# ( debug, non-default config file... )
OPT=
# example: debug output to `mech.debug' file
#OPT=-d -o mech.debug
# example: non-default configuration file
#OPT=-f othermech.conf
# Send output to...
OUTPUT=./mech.cron
#OUTPUT=/dev/null
if [ -r mech.pid ]; then
PID=`cat mech.pid`
if [ -r /proc/$PID ]; then
exit 0
fi
if ( kill -0 $PID 1> /dev/null 2> /dev/null ); then
exit 0
fi
fi
# its not running...
echo >> $OUTPUT
echo "Mech restarted:" >> $OUTPUT
( date 2>&1 ) >> $OUTPUT
echo >> $OUTPUT
( $RUN $OPT 2>&1 ) >> $OUTPUT