LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-13-2019, 09:02 AM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware 14.2 current / ArcoLinux / Void Linux
Posts: 8,826

Rep: Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840
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

Last edited by BW-userx; 07-13-2019 at 09:04 AM.
 
Old 07-13-2019, 09:34 AM   #2
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 4,012
Blog Entries: 3

Rep: Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914Reputation: 1914
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.
 
1 members found this post helpful.
Old 07-13-2019, 10:29 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware 14.2 current / ArcoLinux / Void Linux
Posts: 8,826

Original Poster
Rep: Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840Reputation: 1840
Quote:
Originally Posted by Turbocapitalist View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill a zombie process - which process is the parent that I should kill? Mountain Linux - General 3 12-31-2011 02:44 PM
bash `kill`: process 'B' silently dies; but process 'A' = `kill` spews back debris! GrapefruiTgirl Programming 9 06-23-2009 09:42 AM
why we cannot kill process id 1 with command "kill -9 1" satyaredhat Linux - Newbie 7 03-11-2009 12:48 PM
Shell Script : Kill a running process when another process starts ashmew2 Linux - General 3 08-20-2008 03:47 AM
cannot kill process (kill -9 does not work) mazer13a Linux - General 1 05-27-2005 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration