Discussion:
[Help-bash] Find and stop processes
Danny
2016-12-06 12:45:19 UTC
Permalink
Hi,

I currently have some scripts that are executed via procmail which works just
fine. Just one little issue though, I have no way (apart from doing it manually)
of stopping all of them with one command.

All the scripts are named like this -> "parameters_probe_*.php" (where the * is
the numerical position of the probe).

Is there a way I can search for these filenames (like this):
ps -ax | grep "parameters_probe" then isolate the process ID and then kill them
one by one?

Hope I am making sense.

Thank you

Danny
John McKown
2016-12-06 12:57:11 UTC
Permalink
Post by Danny
Hi,
I currently have some scripts that are executed via procmail which works just
fine. Just one little issue though, I have no way (apart from doing it manually)
of stopping all of them with one command.
All the scripts are named like this -> "parameters_probe_*.php" (where the * is
the numerical position of the probe).
ps -ax | grep "parameters_probe" then isolate the process ID and then kill them
one by one?
Hope I am making sense.
I think you are. Have you looked at the "killall" command?

killall -r 'parameters_probe_[[:digit:]]+\.php'

The value after the "-r" is a regular expression which need to match
the script name as shown in the "ps" command. You can include a "-i"
switch if you want to be asked to confirm each termination (like "rm
-i" does for deleting files).
Post by Danny
Thank you
Danny
--
Heisenberg may have been here.

Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown
Greg Wooledge
2016-12-06 14:26:00 UTC
Permalink
Post by John McKown
Post by Danny
ps -ax | grep "parameters_probe" then isolate the process ID and then kill them
I think you are. Have you looked at the "killall" command?
Please stop advising this. Switch your advice to pkill instead, if
you must support this killing-en-masse-by-name nonsense.

http://mywiki.wooledge.org/ProcessManagement
John McKown
2016-12-06 14:36:01 UTC
Permalink
Post by Greg Wooledge
Post by John McKown
Post by Danny
ps -ax | grep "parameters_probe" then isolate the process ID and then kill them
I think you are. Have you looked at the "killall" command?
Please stop advising this. Switch your advice to pkill instead, if
you must support this killing-en-masse-by-name nonsense.
http://mywiki.wooledge.org/ProcessManagement
Interesting. I've never run across "pkill" and its family. thanks for
the pointer.
--
Heisenberg may have been here.

Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown
Danny
2016-12-08 16:43:28 UTC
Permalink
Thank you

Danny

Loading...