Skip to content

Instantly share code, notes, and snippets.

@thevickypedia
Last active April 16, 2023 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thevickypedia/468a323a813ee2181312a466e0175ea3 to your computer and use it in GitHub Desktop.
Save thevickypedia/468a323a813ee2181312a466e0175ea3 to your computer and use it in GitHub Desktop.
Stop a process with process name in argument
if [[ $1 == "" ]]
then
echo "Pass process name as argument"
exit
else
echo "Stopping PIDs for $1"
fi
for pid in $(ps -ef | grep $1 | awk '{print $2}'); do echo "Stopping pid $pid" && kill -9 $pid; done
# for pid in $(ps -ef | awk '/$1/ {print $2}'); do echo "Stopping pid $pid" && kill -9 $pid; done
# alias for stopping processes
# alias stop='bash ~/stop_process.sh'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment