Is it possible to attach to a running matlab process?

I have a matlab process which executes a function for a week or so. I would like to attach to this process to examine some variables' values. Is it possible to attach to a running matlab process in a similar way like I can attach to a running process using GDB? My matlab version is 2012b if it makes any difference
Thanks in advance

Answers (1)

Assuming you are using Linux and want to attach over ssh (or something similar) you should look at the answers to this question which suggest using SCREEN (although some people suggest VNC). You should also take a look at this question which provides some warnings about long running processes.

3 Comments

Unfortunately, this is not the answer I was looking for. You suggest to run Matlab process using the screen command which is a good idea. However, my problem is that my process is already running using nohup and I want to attach to it in it's current form. Next time I'll run this process, I will defiantly run it using screen or equivalently use nomachine session. Using the graphical interface it is easy to stop and resume scripts execution but again this is not the case I'm looking to solve. The current execution is "only" few weeks old but we can imagine a more extreme situation where the execution is few months old or even more than that. In such case loosing the execution is a shame and this is what I would like to solve. Given a matlab process which runs a script for some time, without restarting the process, is there a way to attach to this process in order to examine the variable values. Hacking is very welcomed.
dpb
dpb on 10 Aug 2013
Edited: dpb on 11 Aug 2013
This doesn't answer your direct question, either, but, for the future you might consider modifying the application(s) that are so long to use shared memory via memory mapping and have them update that memory periodically so a second process can access it.
I don't know enough of the unix side of things to have any suggestions for directly attaching to another existing image, sorry...
I'm having this problem, too. I use tmux to run matlab. But now it paused at somewhere. So I'm looking for a method to start a debugger and attach debugger to this process to see what happened, not just inspect its stdout. While for C program, GDB can implement this. Is it possible for matlab?

Sign in to comment.

Categories

Asked:

on 7 Aug 2013

Commented:

on 4 Apr 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!