Last active
May 2, 2024 02:58
-
-
Save rmtbb/3da43e9f5b03392dbe5d74e09a43f556 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
nohup bash -c "ps aux | grep '[s]ay' | awk '{print \$2}' | xargs kill" & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Antidote: Shut Your Computer Up
to use via curl:
This script is designed to identify and terminate all processes related to the
say
command that are currently running on a Unix-like operating system. It is executed in the background usingnohup
, ensuring that it continues to run even if the terminal is closed or the user logs out.Command Explanation
nohup
:nohup
stands for "no hang up." This utility allows the command to run in the background immune to hangups, with output directed to a non-tty. This means it will continue operating even after the initiating terminal is closed.bash -c "..."
:-c
option allows passing the entire command pipeline as a single string.ps aux | grep '[s]ay' | awk '{print \$2}' | xargs kill
:ps aux
: This command displays all running processes with detailed information about each process.grep '[s]ay'
: Filters the list of processes to include only those containing the stringsay
. The bracket notation[s]ay
is used to avoid listing the grep process itself in the output.awk '{print \$2}'
: Extracts the second column from the output, which typically contains the process ID (PID) of the matching processes.xargs kill
: Takes the list of PIDs from the output ofawk
and passes them as arguments tokill
, terminating each process.&
:Use Case
This script is particularly useful in environments where the
say
command might be executed frequently or inappropriately, allowing system administrators to quickly terminate all such processes without having to manually identify and kill them one by one.Conclusion
This script provides a quick and efficient way to manage system resources by terminating unwanted or rogue instances of the
say
command, enhancing system performance and security.