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?

4 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 21 Gen 2010

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.

Più risposte (1)

Leon
Leon il 29 Ago 2018
The command seems to be truncated. Anyone has the full command?
Thanks!
  2 Commenti
Walter Roberson
Walter Roberson il 29 Ago 2018

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.)

Accedi per commentare.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti


Release

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by