Skip to content

Commit bbb4605

Browse files
authored
Added Kill Processes Running od specific ports (#1005)
1 parent b55bd77 commit bbb4605

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Required parameters:
4+
# @raycast.schemaVersion 1
5+
# @raycast.title Kill a process on PORT
6+
# @raycast.mode compact
7+
8+
# Optional parameters:
9+
# @raycast.icon 🚫
10+
# @raycast.argument1 { "type": "text", "placeholder": "Ports (e.g. 3000 5000)" }
11+
12+
# Documentation:
13+
# @raycast.description Kill running processes on the given ports
14+
# @raycast.author aaqifshafi
15+
# @raycast.authorURL https://github.com/aaqifshafi
16+
17+
if [ $# -eq 0 ]; then
18+
echo "Provide at least one port number."
19+
exit 1
20+
fi
21+
22+
for port in "$@"
23+
do
24+
pid=$(lsof -ti tcp:$port)
25+
if [ -n "$pid" ]; then
26+
kill -9 $pid
27+
echo "Killed process $pid on port $port"
28+
else
29+
echo "No process found on port $port"
30+
fi
31+
done

0 commit comments

Comments
 (0)