0

I have Matlab running in a Linux session for almost 2 days, and afraid to lose the computations if my network connection fails. Will moving Matlab to the background and starting 'screen' be the answer for that?

Aviv
  • 3

2 Answers2

0

No. Your Matlab output will not magically appear in the screen session for that you need to first start screen then start the matlab session within it. The same holds true for tmux.

If you want to reconnect the stdin/out of this running process to another you can try reptyr

Anthon
  • 79,293
0

No, starting a screen session after a process is started will not help. What you can try is just putting the process in the background. On my Linux (Mint 17) I tried it with another shell and put 'sleep 100000` in the background.

Then I logged off the session and started a new one. The sleep 100000 process was still running and the parent became process 1 (the init process).

Steps were:

sleep 100000

Ctrl+z

bg 1

ps -ef |grep sleep
testuser   7482  7320  0 14:44 pts/11   00:00:00 sleep 10000000

logoff

logon

ps -ef |grep sleep
testuser   7482     1  0 14:44 ?        00:00:00 sleep 10000000

Other systems like Solaris has the nohup command which allows you to specify a pid to immune to hangups.

Lambert
  • 12,680
  • The process is indeed still running, but you can't reconnect to it (STDIN/STDOUT). I needed to reconnect to the Matlab session. – Aviv Apr 02 '15 at 09:18
  • Use reptyr [-s] pid in that case, as @Anthon suggested, to reconnect the file descriptors. – Lambert Apr 02 '15 at 18:49