Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alamindevms/caa0df680f38f02bbdea8db40e9e0eab to your computer and use it in GitHub Desktop.
Save alamindevms/caa0df680f38f02bbdea8db40e9e0eab to your computer and use it in GitHub Desktop.
Follow the steps to use this script
If you need to add process name then modify the PROCESS_NAMES() value.
Step 1:
Save the script to a file, for example, stop_processes.sh
Step 2:
Make the script executable: chmod +x stop_processes.sh
Step 3:
Run the script whenever your PC slows down: ./stop_processes.sh
Note: It is written specifically for Unix-like operating systems (such as Linux or macOS).
#file: stop_processes.sh
# List of process names to be stopped
PROCESS_NAMES=("chrome")
for PROCESS_NAME in "${PROCESS_NAMES[@]}"
do
PIDS=$(pgrep $PROCESS_NAME)
echo "Name - $PROCESS_NAME | PIDS - $PIDS"
for PID in $PIDS
do
kill $PID
if kill -0 $PID &> /dev/null; then
kill -9 $PID
echo "Killed $PID"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment