Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bad error handling when using matlab -r in terminal with nohup

448 views
Skip to first unread message

René

unread,
Feb 28, 2011, 5:30:11 PM2/28/11
to
Hi,

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]

Philip Borghesani

unread,
Mar 1, 2011, 1:21:05 PM3/1/11
to
On 2/28/2011 5:30 PM, René wrote:
> Hi,
> 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:
>

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

0 new messages