Running MATLAB in Batch Mode
MATLAB jobs can be run in batch mode by passing MATLAB the sequence of commands. Here is an example shell script for bash shell users,
#!/bin/sh
DISPLAY=""
export DISPLAY
matlab << END_TAG
my_matlab_script.m
save my_matlab_output
quit
END_TAG
# Wait for any running jobs to finish.
wait
The list of MATLAB commands are placed between the first and second
END_TAG statements. Alternatively, one could just direct a
normal MATLAB script as input to the matlab command.
#!/bin/sh
DISPLAY=""
export DISPLAY
matlab < my_matlab_script.m
# Wait for any running jobs to finish.
wait
Notes:
- It is important to set the DISPLAY environment variable to "" before invoking MATLAB commands to disable graphics during batch jobs.
- As a courtesy to other users, large MATLAB jobs should be appropriately niced.
- To make your immune to hangups or accidental logouts, use the nohup command.