# How to kill the kernel process from the command line without killing the frontend?

Sometimes the kernel hangs and I'd like to see if I can kill the math-kernel process without destroying my front-end session and losing the changes in my unsaved notebook!

• I believe @Rojo made something to autosave the notebook automatically before each run some time ago – Dr. belisarius Feb 14 '15 at 20:56
• Usually I just go into Task Manager on Windows and manually kill the MathKernel objects. I don't think I've experienced failures with this, but maybe others have experienced otherwise? – DumpsterDoofus Feb 14 '15 at 21:14
• @DumpsterDoofus: Same here, have never had a problem with losing NB... – ciao Feb 14 '15 at 21:52
• I've experienced many permutations of possibilities. On which versions, whether betas or not, etc., are all confused in my memory. If the front end is not hung, I can (almost always) save while the kernel is running, as well as kill the kernel from the command line without crashing the front end. If the front end is hung, then sometimes the front crashes when the kernel is killed; but this has not yet happened with V10.0.2. In V10.0.2, killing the kernel has been "safe" (knock on wood). – Michael E2 Feb 14 '15 at 23:16
• – Michael E2 Feb 14 '15 at 23:18

## 1 Answer

In your aliases file (~/.zsh_aliases) add

alias a=alias
a km='kill -9 pidof WolframKernel'


Reload your shell. Now, if the front-end is hanging and you can't quit the kernel but don't want to lose your unsaved notebook changes, simply open a shell and type

km


Presto, kernels killed!

On OSX, if you don't have the pidof command do brew install pidof.