OS : window 10
Mathematica : v12.2

By my mistake, I opened another mathematica kernel, not knowing a kernel was already running.

I created a lot of .nb files and worked on them in another kernel, while one kernel was already running with many working .nb.

All .nb are still open.

In this state, how can I know which kernel is handling which .nb file?

I guess that there exist ID(a serial?) concept for both kernel and working .nb file.

And I guess that by executing some command on a working .nb, it is possible to figure out the ID of .nb file and the ID of kernel which handles the working .nb.

  • 3
    $\begingroup$ There is $SessionID. See also SessionTime. $\endgroup$
    – user293787
    Oct 23, 2022 at 3:42
  • 1
    $\begingroup$ You can of course also define $abc=1 (any name you like) in one notebook, then evaluate $abc in other notebooks to see whether they have a value for $abc. $\endgroup$
    – user293787
    Oct 23, 2022 at 3:47
  • $\begingroup$ Thank you! $SessionID is like an ID for a kernel. $\endgroup$
    – imida k
    Oct 23, 2022 at 6:35
  • $\begingroup$ Also $ParentLink $\endgroup$
    – rnotlnglgq
    Oct 23, 2022 at 15:58

1 Answer 1


This answer assumes that you have opened 2 kernels by calling 2 times the frontend. So each kernel is connected to one frontend.

This code highlights all the notebooks linked to the same FrontEnd :

CurrentValue[$FrontEndSession, Background] = Pink

The color Pink doesn't remain between sessions (because $$FrontEndSession is used, as opposed to $FrontEnd)

  • $\begingroup$ Great. But Pink makes it now very hard to read the code and look at the notebook now. But nice to know there is way to do this. $\endgroup$
    – Nasser
    Oct 23, 2022 at 16:04
  • $\begingroup$ @Nasser I have used Pink to be certain that is not the FontColor the reader use, otherwise ... $\endgroup$
    – andre314
    Oct 23, 2022 at 16:06
  • $\begingroup$ It will be better if WRI made a way to just add some text to each notebook, at the very top edge of the notebook, where the menu is, giving the kernel ID it is using. This way no need to change colors, which most likely will not be something many want to do. So one just have to look at the top and see the ID. $\endgroup$
    – Nasser
    Oct 23, 2022 at 16:09
  • $\begingroup$ @Nasser See my edit. ( Maybe you are not aware) $\endgroup$
    – andre314
    Oct 23, 2022 at 16:13

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