Last active
July 1, 2024 17:03
-
-
Save alamindevms/caa0df680f38f02bbdea8db40e9e0eab to your computer and use it in GitHub Desktop.
Follow the steps to use this script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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