Pkill -f doesn't work to kill process

I have this process:

342 pts/2 T 0:00 sh -c sudo screen /usr/bin/python /usr/bin/btdownloadcurses "http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent" --display_interval 20 --saveas "/srv/" 343 pts/2 T 0:00 sudo screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/ 344 pts/2 T 0:00 screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/ 

I tried to run:

 pkill -f http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent 

But the process is still running.
How to make kill processes that contain: " http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent "?


Question edited below:

 ps ax | grep 'Momomoko.E01.140011.HDTV.H264.720p.mp4' 

I want to kill the whole process containing the above line.

I tried to execute the above line and it returns three results:

  342 pts/2 T 0:00 sh -c sudo screen /usr/bin/python /usr/bin/btdownloadcurses "http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent" --display_interval 20 --saveas "/srv/Momomoko.E01.140011.HDTV.H264.720p.mp4" 343 pts/2 T 0:00 sudo screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/Momomoko.E01.140011.HDTV.H264.720p.mp4 344 pts/2 T 0:00 screen /usr/bin/python /usr/bin/btdownloadcurses http://zoink.it/torrent/732A4A9B54B7E3A916C2835D936D985942F65A6D.torrent --display_interval 20 --saveas /srv/Momomoko.E01.140011.HDTV.H264.720p.mp4 

How to run this line:

 ps ax | grep 'Momomoko.E01.140011.HDTV.H264.720p.mp4' 

.. with php and kill -9 all the relevant processes?

+5
source share
2 answers

As you can see, the process is started using the on-screen command.

 sh -c sudo screen /usr/bin/python sudo screen /usr/bin/python screen /usr/bin/python 

Because of this, you cannot kill process using the command you used.

To kill a process, first search for the process ID of the process PID , and then use the kill command with the PID. how

 $ **kill -9 342** 

Also, looking from your list of processes, you can see that you started the same process many times with different resolutions. Therefore, I suggest that you kill everyone except the ones you need.

EDIT: This single command will suffice;

 $ ps ax | grep 'Momomoko.E01.140011.HDTV.H264.720p.mp4' | awk -F ' ' '{print $1}' | xargs sudo kill -9 

Here is what he does:

  • ps ax: specify the process
  • grep: grep for the name of the requested process
  • awk: get only the process PID from grep ouput
  • xargs sudo kill -9: xargs will pass the PID number one by one to kill the command
+5
source

Try using the kill command sooner

 kill -9 <pid> 

It will work for sure because I tried it myself and it is very convenient all the time.

Use the following in the script file, then run the loop with the kill command,

 ps|grep torrent|cut -f1 -d' ' 

like this for a loop, as shown below, as an exact working copy from my system;

 for p in `ps|grep torrent|cut -f1 -d' '`; do kill -9 $p done 

Hope this helps you at last.

+1
source

Source: https://habr.com/ru/post/1206774/


All Articles