This commit is contained in:
xin
2025-11-04 17:19:32 +08:00
parent 030381aa5c
commit 7c9b5728b9
37 changed files with 677 additions and 191 deletions

29
root/Mywathdogtemp.sh Normal file
View File

@ -0,0 +1,29 @@
#!/bin/bash
while true
do
time=`date +%H:%M:%S`
echo $time
if [[ "$time" > "01:00:01" ]] && [[ "$time" < "22:30:00" ]]
then
ps -ef | grep "TemperatureControler" | grep -v "grep"
if [ "$?" -eq 1 ]
then
/home/pi/bin/TemperatureControler &
echo "process has been restarted!" > /home/data/log.txt
else
echo "process already started!"
sleep 60
fi
else
pid=$(ps -ef | grep "TemperatureControler" | grep -v "grep" | awk '{print $2}')
if [ -z "$pid" ]
then
sleep 60
else
echo "$?"
echo "time to kill the task" > /home/data/log.txt
kill "$pid"
fi
fi
sleep 30
done