Files
AireOptoSifAndSpectral/root/Mywathdogtemp.sh

30 lines
720 B
Bash
Raw Permalink Normal View History

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