Skip to content

Commit 2b2ae71

Browse files
committed
2015.02.28
1 parent 6e9aee0 commit 2b2ae71

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

python/kill_5037.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
'''
5+
Created on 2015年2月28日
6+
7+
@author: xuxu
8+
'''
9+
10+
import os
11+
12+
from scriptUtils import utils
13+
14+
#5037端口占用时杀掉占用该端口的进程
15+
16+
def linux():
17+
pid = os.popen("netstat -anop | grep 5037 | grep LISTEN").read().split()[6].split("/")[0]
18+
os.system("kill %s" %pid)
19+
20+
def win():
21+
pid = os.popen("netstat -ano | findstr 5037 | findstr LISTENING").read().split()[-1]
22+
os.system("taskkill /F /PID %s" %pid)
23+
24+
25+
if __name__ == "__main__":
26+
if utils.system is "Windows":
27+
win()
28+
else:
29+
linux()

0 commit comments

Comments
 (0)