I made an alias for this function to kill processes in bash:
In my .bashrc file
kill_process(){ # $1 being a parameter for the process name kill $(ps ax | grep "$1" | awk '{print $1}') } alias kill_process=kill_process
So, suppose I want to kill the meteor process:
Look at all the meteor shower processes:
ps aux | grep 'meteor' | awk '{print $2}' 21565 21602 21575 21546
Call the kill_process function with an alias
kill_process meteor bash: kill: (21612) - No such process
So, the kill_process function effectively terminates the meteor processes, but the kill command looks for a nonexistent pid. Please note that pid 21612 not specified ps aux | grep ps aux | grep . Any ideas on improving the kill_process function to avoid this?
source share