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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -