Last active
February 18, 2024 10:20
-
-
Save harshithjv/9c6499e36094d07ccf9e31d0af53ddfb to your computer and use it in GitHub Desktop.
Killing all celery processes in one line.
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
# Killing all celery processes involves 'grep'ing on 'ps' command and run kill command on all PID. Greping | |
# on ps command results in showing up self process info of grep command. In order to skip that PID, 'grep | |
# -v grep' command is piplined which executes 'not' condition on 'grep' search key. The 'awk' command is | |
# used to filter only 2nd and 'tr' command translates result of 'awk' command output from rows to columns. | |
# Piplining 'kill' command did not work and so the entire process has been set as command substitution, i.e., | |
# '$()'. The redirection at the end is not mandatory. Its only to supress the enitre output into background. | |
kill -9 $(ps aux | grep celery | grep -v grep | awk '{print $2}' | tr '\n' ' ') > /dev/null 2>&1 |
ps aux|grep celery
kill -9 $(ps aux | grep celery | grep -v grep | awk '{print $2}' | tr '\n' ' ') > /dev/null 2>&1
pkill -9 -f celery
))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Verify Github on Galaxy. gid:iGj7FA8dCWPUxUvXuX3RjY