Is there a way to detach/reattach the Frontend from a running Mathematica Kernel?

This comes a little late, but this is my solution:

Remote Machine running linux with tmux (similar to screen but newer, should work with screen but I dont know the commands) and Mathematica 10 installed.

Local Machine running MacOS Yosemite with Mathematica 10.

  1. Launch tmux in remote machine and execute Mathematica:

    tmux

    wolfram (executable to mathematica in terminal mode)

  2. Now create a link with TCPIP protocol. Record the linkname="linkPort1@remoteIP,linkPort2@remoteIP" generated.

    link=LinkCreate[LinkProtocol -> "TCPIP"]                                
    LinkObject[linkPort1@remoteIP,linkPort2@remoteIP, 72, 1]
    
  3. Now in local machine, start Mathematica and go to Evaluation->Kernel Configuration Options -> Add... and fill out the window just as showed below.Dont forget to replace (insert remote ip ) by the remote machine ip address and insertLinkName by the link name that was generated above enter image description here clic ok. Then open a new notebook and set the above created kernel as the notebooks kernel. Dont evaluate anything yet in this notebook.

  4. Go back to your remote machine and run

    $ParentLink=link
    
  5. Finally go back to the notebook in your local machine and evaluate something:

    $Version 
    

So now you are running the kernel in the remote machine with the front end in your local machine.

  1. To disconnect from the Kernel, evaluate the following in your notebook:

    LinkClose /@ Links[]
    

At this point your kernel is still running in the remote machine. To reattach follow steps 2 through 5.

This could be automatized with a script. Also if you know that a port is always available, you could set the link with a persisten name so that you dont have to reconfigure the remote kernel each time you attach.


I have not done this before, but here's how I would approach this:

run the kernel on the remote machine from the command line using the 'background process' approach (i.e. '&' or "start")...

then run a script that will dump out the Mathlink connection id (or equivalent)...pass this to the front-end you want to be the client and start/restart the Mathlink connection...