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!

  • $\begingroup$ I believe @Rojo made something to autosave the notebook automatically before each run some time ago $\endgroup$ – Dr. belisarius Feb 14 '15 at 20:56
  • 1
    $\begingroup$ 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? $\endgroup$ – DumpsterDoofus Feb 14 '15 at 21:14
  • $\begingroup$ @DumpsterDoofus: Same here, have never had a problem with losing NB... $\endgroup$ – ciao Feb 14 '15 at 21:52
  • $\begingroup$ 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). $\endgroup$ – Michael E2 Feb 14 '15 at 23:16
  • $\begingroup$ Related: mathematica.stackexchange.com/q/13997 and mathematica.stackexchange.com/a/8762/5 $\endgroup$ – Michael E2 Feb 14 '15 at 23:18

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


Presto, kernels killed!

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.