This will force kill emacs daemon from bash
. If there is no emacs running and when we run emacsclient -e "(kill-emacs)"
, which starts emacs and kills it again. I just added simple if/else to prevent that.
- Instead of
kill-emacs
you can use brutally-kill-emacs ()
that is defined in @Constantine's answer.
#!/bin/bash
num=$(ps aux | grep -E "[e]macs --daemon" | wc -l)
if [ $num -ge 1 ]; then
emacsclient -e "(brutally-kill-emacs)" > /dev/null 2>&1
# following commands guarantees
kill -9 $(ps aux | grep -E "emacs" | awk '{print $2}')
(killall emacs) > /dev/null 2>&1
(killall emacsclient) > /dev/null 2>&1
kill -9 $(ps aux | grep -E "[e]macs" | awk '{print $2}') > /dev/null 2>&1
else
echo "emacs is already killed."
fi
----
If you are a m
Sometimes following zombie process remain opened and consumes all the memory so `kill -9 $(ps aux | grep -E "emacs" | awk '{print $2}')` will be your friend.
alper 4785 100.0 0.0 4461068 7860 ?? R 1:27AM 41:42.43 /usr/local/Cellar/emacs-head@26/26.3_1/Emacs.app/Contents/MacOS/Emacs -Q -l /Users/alper/.emacs.d/elpa/async-20200809.501/async.elc -batch -f async-batch-invoke