I'm now facing this situation: I'm running several Matlab instances on a computation server (server OS: Xubuntu 14.04, my local machine OS: Ubuntu 14.04). I used NoMachine to connect to the server. NoMachine usually works fine but last time, NoMachine froze and I had to force close NoMachine. When I restarted the NoMachine and connected back to the server, I found all windows/GUI of my Matlab instances disappeared. They are now running in the background, as I can see them in top, and they are still consuming a fair amount of CPU resources. Plus, I still can observe the data processing output in the output folder I directed Matlab to save the processed data, so I can safely say they are running fine in the background. However, I lost all window/GUI of all Matlab instances.

In the image, the top command shows matlabs are still running and consuming a fair amount of CPU resources

How can I reclaim these window/GUI? More specifically, I want to restore this window of the matlab instance running in the background.

This is the Matlab GUI I want to reclaim

I can see the PID of Matlab from top. So, does there exist some built-in terminal command like setWindowToFront(PID) that helps me to reclaim the lost windows by PID? Preferably built-in command because I am not privileged to install any package/application on the school server machine.

ps. I can't afford to kill the matlab instance and restart matlab, because the computation takes one month to finish, and I'm just halfway done now.

ps. bg or fg command can't help, they show "no jobs"

ps. the windows/GUI can't be in other workspaces because I have just one workspace.

ps. I didn't launch matlab via terminal in the first place. I launched matlab by mouse clicking.

Many thanks!

  • Could you install wmctrl then run wmctrl -l see if the windows still listed (ie, window manager is aware of them) – user.dz Jan 22 '16 at 22:09
  • @Sneetsher Thanks for the reply. I am not privileged to install any package on the server machine because my user account is not in the sudo group. Is there any equivalent builtin terminal command that does not require other package? If not, I will have to require the package be installed via administrator. Could you please also advise what to do next if the windows are listed in wmctrl and what if they aren't? Thank you! – Ray Jan 23 '16 at 17:06
  • I'm not aware on any default installed alternatives, but only 4 dependencies which seem all already installed by default check apt-cache depends wmctrl . I wrote it as answer. If hidden windows are not listed, not sure how nomachine works, but expect it may open a session with different DISPLAY. – user.dz Jan 23 '16 at 18:20
  1. Get a copy of wmctrl, it is a simple & single command package

    apt-get download wmctrl
    mkdir wmctrl_deleteme
    dpkg-deb -X wmctrl_1.07-7_amd64.deb wmctrl_deleteme/
    cd wmctrl_deleteme/usr/bin/

    Better to put it in ~/bin for easy use.

  2. Check it those windows are managed by WM

    ./wmctrl -l
  3. If it they are listed, try this option (man wmctrl)

       -R <WIN>
              Move the window <WIN> to the current desktop, raise the window, and give it focus.

    Either using window title or id, Examples:

    ./wmctrl -R Home
    ./wmctrl -i -R 0x02e00238
  • 1
    thanks for your prompt reply! I did as per your instruction, but unfortunately wmctrl -l didn't list any Matlab's GUI/window. But thanks very much for pointing out the way NoMachine works. I did a simple experiment. I opened NoMachine, connected to the server, logged in and opened some windows. While keeping this session active, I opened another NoMachine instance, connected to the server and logged in (the same user) again. I got a brand new clean desktop despite that I opened some windows in my first session. Now the cause of this problem is pretty clear. – Ray Jan 25 '16 at 13:59
  • 2
    (continued) Because I forced close NoMachine, it didn't send a disconnect signal to the server. The server thinks my session is still active. So when I reconnect, it prevents the same user logging into the same session twice. It simply gives me a brand new session with a clean desktop. That's why I can't see the programs I ran in the very first session. Now I need to research on how to restore the session, or how to let the server know the very first session is already broken. Thanks a lot!! Have a nice day :) – Ray Jan 25 '16 at 14:00
  • oh by the way, is dpkg-deb a way to bypass the user group constraints to install program? – Ray Jan 25 '16 at 14:05
  • @Ray , yes it is one of some when dealing with programs that does not need root permissions, quiet independent of central services (ex: dconf) , see askubuntu.com/questions/339/… – user.dz Jan 25 '16 at 14:32

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.