I experience some, let's say interesting, problems when using matlab from the terminal with nohup. Example:
nohup matlab -nodisplay -r script.m >output.dat
Nohup ignores all inputs and redirects every output to output.dat. Works fine, as long as there is no error in script.m. If there is an error, matlab will not terminate but instead write "bad file descriptor" to output.dat - and this basically infinitely until I manually terminate matlab. This happened to me in an overnight computation, filling 176G (!) of my RAID with "bad file descriptor".
Anyways, googling and playing around a bit, the following input works better:
nohup matlab -nodisplay <script.m >output.dat
terminating correctly when the error occurs in script.m. However, why is the -r option so picky here? Also, as far as I understand, if script.m is a function, I can only pass values to it in the command line using the -r option, right?
Would be happy about comments/ suggestions.
[Using matlab on a 64-bit ubuntu system]
Try:
nohup matlab -nodisplay -r "try;script;catch; exit(1) ;end" > output.dat
With this code MATLAB will return an error status of 1 back to the
calling shell.
matlab -r will execute all input exactly as if the user typed the input
at the MATLAB command line. Your input of script.m is an error but the
error never happens in the case of success because I your script has an
exit statement in it that runs before attempting to reference .m on the
non existent output of the script.
Phil