LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   kill process from script (https://www.linuxquestions.org/questions/linux-general-1/kill-process-from-script-4175657315/)

BW-userx 07-13-2019 09:02 AM

kill process from script
 
systemD, this script is calling other scripts within it, maybe that is it. but kill pidID is not working on it, either method I use, kill PIDID , of here using xargs.
Code:

$ pgrep fetchwp | xargs kill
$ ps | grep fetchwp
userx    20104  0.0  0.0  7232  3860 pts/0    T    08:51  0:00      \_ /bin/bash /home/userx/bin/fetchwp
userx    9998  0.0  0.0  7232  3648 pts/1    T    08:38  0:00      \_ /bin/bash /home/userx/bin/fetchwp
userx    20488  0.0  0.0  7232  3716 pts/3    T    08:52  0:00      \_ /bin/bash /home/userx/bin/fetchwp
userx    28051  0.0  0.0  6264  2216 pts/3    S+  08:58  0:00      \_ grep --color=auto fetchwp


Turbocapitalist 07-13-2019 09:34 AM

There are several ways to get the PID of the script but, for the way you are trying, use the -f option with pgrep so that it will check the pattern given against the full command with options.

Code:

pgrep -f fetchwp | xargs kill
pkill -f fetchwp

Beware false positives.

BW-userx 07-13-2019 10:29 AM

Quote:

Originally Posted by Turbocapitalist (Post 6014640)
There are several ways to get the PID of the script but, for the way you are trying, use the -f option with pgrep so that it will check the pattern given against the full command with options.

Code:

pgrep -f fetchwp | xargs kill
pkill -f fetchwp

Beware false positives.

thanks, testing scripts, gets me lots of PIDs of same script, I'll remember the -f , as I've already rebooted.


All times are GMT -5. The time now is 01:51 PM.