-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsoftware_wd.sh
executable file
·60 lines (47 loc) · 1.78 KB
/
software_wd.sh
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
55
56
57
58
59
60
#!/bin/sh
##############################################################################
## Copyright (c) 2007-2008, Calaos. All Rights Reserved.
##
## This file is part of Calaos Home.
##
## Calaos Home is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## Calaos Home is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Foobar; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
##############################################################################
#
# A simple software watchdog
#
if [ $# -lt 1 ] ; then
echo "Software Watchdog - Copyright (c) Calaos"
echo "Usage: $0 [app 1] ... [app n]"
exit 1
fi
CMD_LIST=$@
#sleep 60s first a start, to let app to load correctly
sleep 60
while true ; do
for cmd in $CMD_LIST ; do
WD_FILE="/tmp/wd_$cmd"
if [ -e $WD_FILE ] ; then
#wd file present, program is still running
rm -f $WD_FILE
else
#wd file not present, program is somehow blocking
logger -t watchdog -- "Kill process: $cmd"
killall -9 $cmd > /dev/null 2> /dev/null
fi
done
#wait some time before the next check
sleep 10
done