Skip to content

Instantly share code, notes, and snippets.

@rmtbb
Last active May 2, 2024 02:58
Show Gist options
  • Save rmtbb/3da43e9f5b03392dbe5d74e09a43f556 to your computer and use it in GitHub Desktop.
Save rmtbb/3da43e9f5b03392dbe5d74e09a43f556 to your computer and use it in GitHub Desktop.
nohup bash -c "ps aux | grep '[s]ay' | awk '{print \$2}' | xargs kill" &
@rmtbb
Copy link
Author

rmtbb commented May 2, 2024

The Antidote: Shut Your Computer Up

to use via curl:

curl -s https://gist.githubusercontent.com/rmtbb/3da43e9f5b03392dbe5d74e09a43f556/raw/38359290144829a7276824a96a778329e3607487/macNumbersPrankAntidote.sh | bash

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 using nohup, ensuring that it continues to run even if the terminal is closed or the user logs out.

Command Explanation

  1. 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.
  2. bash -c "...":

    • This command instructs the system to execute the enclosed string as a command using Bash. The -c option allows passing the entire command pipeline as a single string.
  3. 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 string say. 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 of awk and passes them as arguments to kill, terminating each process.
  4. &:

    • This symbol places the command into the background. This allows the terminal to be used for other tasks while the command runs indefinitely in the background.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment