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

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -