воскресенье, 20 октября 2019 г.

service_motion.sh

nano service_motion.sh:
-----------------------------------------------------------------
#!/bin/bash
while true; do

#P=$(ps aux | grep -v color | grep -E "service-pir.sh" | grep -E "T" | awk '{print $2}' | head -n 1)
#kill -9 $P

if [ `ps -ef| grep -E "*rec_pir.py" | wc -l ` -gt 1 ]
    then
      echo " is running"
    else truncate -s 0 /tmp/p1s
         ps aux |grep -v color|grep -v grep | grep "/py/rec_pir.py" | awk '{print $2}' > /tmp/p1s
         for i in $(cat /tmp/p1s); do echo " kill $i"; kill -9 $i; done
         ps aux|grep -v color|grep -v grep|grep "/py/rec_pir.py"
         /usr/bin/python3 /py/rec_pir.py &
         echo " restart"
#     if [ `ps -ef| grep -E "*camera.py" | wc -l ` -gt 1 ]
#     then
#      echo " is running camera.py "
#      PS1=$(ps aux | grep -E "*camera.py" | grep -v color | grep -v bash | grep -v grep | awk '{print $2}')
#      echo " $PS1"
#      kill -9 $PS1
#      sleep 1
#      /usr/bin/python3 /py/rec_pir.py &
#      echo " restart"
# fi
fi

sleep 10
done

--------------------------------------------------------------------------

nano ps_kill_motion.sh:
truncate -s 0 /tmp/p1s
ps aux |grep -v color|grep -v grep | grep "/py/rec_pir.py" | awk '{print $2}' > /tmp/p1s
for i in $(cat /tmp/p1s); do echo " kill $i"; kill -9 $i; done
ps aux|grep -v color|grep -v grep|grep "/py/rec_pir.py"
--------------------------------------------------------------------------

Комментариев нет:

Отправить комментарий

h265.sh

#!/bin/bash file="../mp4" if [ -d $file ]; then         echo "  Директория существует :-) "         for i in *.mp4; do f...