- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_kill.py
More file actions
Latest commit
29 lines (25 loc) · 672 Bytes
/
Copy pathprocess_kill.py
File metadata and controls
29 lines (25 loc) · 672 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
importos
fromsysimportargv
defpid(name):
command='ps -e | grep %s'%name
pid_txt=os.popen(command).readlines()
iflen(pid_txt) ==0:
print("None")
return
else:
forlineinpid_txt:
colum=line.split()
pid=colum[0]
command="kill -9 %d"%int(pid)
rc=os.system(command)
ifrc==0:
print("Success! kill %s"%name)
else:
print("Faled! kill %s"%name)
return
if__name__=="__main__":
iflen(argv) ==1:
name=raw_input("Enter process name: ")
else:
name=argv[1]
pid(name)