How can I run MATLAB in batch mode on my Mac when I log in remotely so that the process runs when I am logged out?

조회 수: 1 (최근 30일)
I want to run MATLAB in batch mode on my Mac machine when I log in remotely through SSH. I have tried to use NOHUP, but the process dies as soon as I log off.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2010년 1월 21일

In order to start your MATLAB process through the SSH connection and leave it running after you disconnect, you need to use the following commands on the csh/tcsh shell on the Mac:

 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.

추가 답변 (1개)

Leon
Leon 2018년 8월 29일
The command seems to be truncated. Anyone has the full command?
Thanks!
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 8월 29일

The command is not truncated, but it does depend upon an alias having been created pointing matlab to the correct location, or at least that /Applications/MATLAB_R20XXx.app/bin/ being on the path.

The command given is for csh / tcsh, which is an odd thing to have given as it is not the default for Mac. The default or Mac is bash. The bash equivalent would be

 nohup matlab -r mybgprocess -nodisplay -nosplash -nojvm -nodesktop > matlab.out 2>&1 < mystdio.txt &

Here, matlab.out indicates the name of the file where all of the output is to be sent, and mystdio.txt indicates the name of the file from which all input() statements are to take their input (might affect what happens for keyboard() as well.)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by