赞
踩
最近在rk3399pro开发板上编写python程序(opencv获取rtsp流–vpu硬件解码—多进程读取/处理),但是由于远程网络摄像头rtsp流会发生丢包、网络卡顿的现象,导致程序意外退出,现通过设置shell脚本自动启动意外中断的程序。
1、编写/运行shell脚本
vim run.sh #建一个run.sh脚本,写入下面内容
"""
#!/bin/bash
while [ 1 ];do
python test.py
done
"""
chmod +x ./run.sh #设置权限
./run.sh #运行脚本
2、shell脚本退出
#查看进程号(run.sh为shell脚本名)
root@root:~# ps -ef | grep run.sh
root 5783 1397 0 11:04 pts/0 00:00:00 /bin/bash ./run.sh
root 5966 5953 0 11:08 pts/2 00:00:00 grep run.sh
#终止进程
root@root:~# kill -9 5783
一般的shell脚本到这一步就可以退出了,但由于我是多进程,所以还需要把进程再kill一遍。
root@root:~# top #查看进程号
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5797 root 20 0 789124 73788 44760 S 35.1 1.9 2:58.34 python
5798 root 20 0 909916 67728 42960 R 25.6 1.7 2:05.47 python
root@root:~# kill -9 5797 5798 #批量kill 进程
这样退出shell脚本了。
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。