Close the terminal but keep matlab running remotely

14 次查看(过去 30 天)
Hi, I have to run some programs remotely in a cluster.
The problem is the following, the programs run for two or three days (they are really heavy). I connect to the cluster and run the programs with the following command
matlab -nosplash -nodesktop -r script
the program runs properly, but if I close the terminal the program stops running, and if I disconnect from the network the program give me the following error: "broken pipe".
Is any way that I can run the program and I can disconnect or close the terminal and the program keep running?
Thank you very much

采纳的回答

Walter Roberson
Walter Roberson 2013-8-13

Investigate using "screen" or "vnc", if you want to be able to reconnect to the session.

If you want to be able to run the script "in batch", not needing to interact with it after it starts, then if it is a Unix-type system, consider using the system "batch" command, or else use

nohup matlab -nosplash -nodesktop -r "try; script; catch; end" < /dev/null > /dev/null 2> /dev/null

(bourne or ksh derivatives, might need a slightly different syntax on csh)

  5 个评论
Iván
Iván 2013-8-14

Thank you very much for your answers Walter. I finally find the following code that worked for me:

unsetenv DISPLAY
nohup matlab -r mybgprocess -nodisplay -nosplash -nojvm -nodesktop > & ! matlab.out < mystdio.txt &

The file 'mybgprocess.m' contains the MATLAB commands that you want to run. It is important that this function has a QUIT or EXIT statement at the end so that the MATLAB process is closed after you script is done executing. The file 'mystdio.txt' can be an empty file, but it needs to exist. Without this file, the standard input of the MATLAB process would be empty, which would cause the MATLAB process to die. The file 'matlab.out' will store the output of the MATLAB Command Window to your commands.

Source:

http://www.mathworks.com/support/solutions/en/data/1-5P0HFE/?solution=1-5P0HFE

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by