恢复误删除的文件

This commit is contained in:
2022-02-18 15:56:30 +08:00
parent b5771ca64f
commit e7132df842
2 changed files with 32 additions and 1 deletions

28
root/Mywathdog.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/sh
while true
do
time=`date +%H:%M:%S`
echo $time
if [[ "$time" > "01:00:01" ]] && [[ "$time" < "22:30:00" ]]
then
ps -ef | grep "TowerOptoSifAndSpectral" | grep -v "grep"
if [ "$?" -eq 1 ]
then
/home/pi/bin/TowerOptoSifAndSpectral &
echo "process has been restarted!" > /home/data/log.txt
else
echo "process already started!"
sleep 60
fi
else
ps -ef | grep "TowerOptoSifAndSpectral" | grep -v "grep"
if [ "$?" -eq 1 ]
then
sleep 60
else
echo "time to kill the task" > /home/data/log.txt
pkill TowerOptoSifAndSpectral
fi
fi
sleep 30
done