-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcronjobWemoFetchApp_Linux.sh
More file actions
executable file
·47 lines (38 loc) · 1.24 KB
/
Copy pathcronjobWemoFetchApp_Linux.sh
File metadata and controls
executable file
·47 lines (38 loc) · 1.24 KB
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
#!/bin/bash
pythonscriptfile=/teqtools/wemofetchapp/testWemoClass.py
checkModifyFile=/teqtools/wemofetchapp/lastKnownActivity.log
numMinutes=$1
if [ -z "$numMinutes" ]
then
echo "Please pass in a number of minutes allowed for the wemo app to be idle. Exiting.."
exit
fi
date
if [ $(($numMinutes)) -gt 0 ]
then
echo "Is wemo app running? "
ps_run_count=`ps -ef | grep $pythonscriptfile | grep -v grep | wc -l`
echo $ps_run_count
if [ $ps_run_count -gt 0 ]
then
echo "Wemo app is running - checking for activity in last X mins: " $numMinutes
lastUpdatedInXMins=`find $checkModifyFile -mmin -$numMinutes | wc -l`
if [ $((lastUpdatedInXMins)) -eq 0 ]
then
echo "Wemo Fetch App has hung! Killing.."
pidToKill=`pgrep -f $pythonscriptfile`
kill $pidToKill
fi
if [ $((lastUpdatedInXMins)) -gt 0 ]
then
echo "Wemo app is responsive! Exiting.."
exit
fi
fi
#If the app isn't running, start it in the background
if [ $ps_run_count -eq 0 ]
then
/usr/bin/python $pythonscriptfile /teqtools/wemofetchapp/ > /teqtools/wemofetchapp/wemoCronJob.log 2>&1 &
echo "Wemo app started!"
fi
fi