shell - Kill Process from Command Name -
in project need write function take name of command in parameter, , kill process executing command. don't know how go problem. can me please?
assuming mean linux/unix: capture process id of command, can use pgrep
:
pgrep command
this returns process id integer, can pass kill
.
kill -9 $(pgrep command)
command extended regex pattern - pgrep test
match commands called test
, pgrep *test*
match test
, tester
, bashtest
etc. may have access pkill
, similar skips step directly killing process matched.
Comments
Post a Comment