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
Apart from the standard unix ways of killing celery processes, Celery also provides API to kill all the workers listening on a particular broker.
app.control.shutdown()
where app is the celery app instance configured with the broker.
celery -A app_name control shutdown