Please help me script
I want to make a script that lifts a PIDs for rtorrent processes, so far I got this:
netstat -tanpu | grep "rtorrent" gives me a nice list of 7 columns, the PIDs are buried at the end of the 4th column, tcp 0 0 213.321.40.162:6942 85.235.218.114:62649 ESTABLISHED 28387/rtorrent I want to lift off the PID 6942 for instance, and then tell system to kill that process, but sed makes my head hurt.:( How might you do it? |
Quote:
Code:
pgrep rtorrent Code:
kill -INT $(pgrep rtorrent) Code:
for pids in $(pgrep rtorrent) |
Some systems also have the utilites pkill and killall.
|
Quote:
Code:
PID=$(netstat -tanpu | sed -n -e '/rtorrent/s@.*\([0-9]\+\)/rtorrent.*@\1@p') |
Thanks for this, nice solutions and correction there, very helpful indeed.
|
All times are GMT -5. The time now is 09:50 AM. |