-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpidclose.py
More file actions
34 lines (31 loc) · 821 Bytes
/
Copy pathpidclose.py
File metadata and controls
34 lines (31 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
abspath = os.path.abspath(__file__)
filename = os.sep.join(abspath.split(os.sep)[-2:])
abspath = abspath.replace(filename, "")
import sys
sys.path.append(abspath)
def closepid():
pth = os.path.join(abspath, "pid.txt")
os.system(r"ps -aux|grep train_yolov3 |tee %s" % pth)
kk = []
with open(pth, 'r') as obj:
for i in obj.readlines():
if 'grep' in i:
continue
i = i.strip()
i = i.split(" ")
while '' in i:
i.remove('')
kk.append(int(i[1]))
for i in kk:
try:
os.system("kill -9 %d"%i)
except:
pass
for i in kk:
try:
os.system("kill -9 %d"%i)
except:
pass
if __name__=="__main__":
closepid()