背景:
在嵌入式设备中开发,由于资源紧张无法使用现有supervisor,
开发思路
1. 查找运行文件的pid文件
cd /var/run/
1.1 如果pid文件存在 ,查看cmdline
>>>cat /proc/3557/cmdline python3 test1.py 3557 是进程id
1.2 获取的信息,通过关键词该进程id是我们正在执行的python程序
1.3 ps|grep test2.py 获取程序的进程id
ps|grep test2.py 587 root 3840 S grep test2.py 32467 root 10004 S {test2.py} /apps/bin/python3 ./test2.py
2. 如果运行的文件有重名程序
打开要执行的python程序文件,在第一行填写
#!/apps/bin/python3
把文件变成可执行文件
2.1 给python文件增加执行权限
chmod +x test2.py
还没有留言,还不快点抢沙发?