Problem running matlab in batch mode: Connection to X11 server lost, then runaway log file.

3 次查看(过去 30 天)

I am running MatLab 2010b on Ubuntu Linux.

Every time I run my batch script using matlab -r on the Linux command line, the script appears to run to completion, but then (in the log file, after all of the script output) I get the following error:

 Warning:
Connection to the X11 Display Server (:0.0) has been lost.
No more graphics windows can no longer be displayed in this session.
Graphics Objects can still be printed, and all commands should still work.
We recommend that you try to save your current session and exit 
> In run_sim_output_cbrn at 12
??? Operation terminated by user during ==> run_sim_output_cbrn at 12
 >> Invalid file descriptor
Invalid file descriptor
Invalid file descriptor
Invalid file descriptor
Invalid file descriptor
etc....

The phrase "Invalid file descriptor" is output continuously until my disk is full (creating an enormous log file).

At first I ran the script like this:

 > nohup matlab -nojvm -r batch_script.m -logfile batch.log &

Then I tried it again by putting the matlab command (matlab -nojvm -r batch_script.m -logfile batch.log) in a shell script called run_matlab_batch.cmd and then doing

 > nohup run_matlab_batch.cmd &

In both cases I end up with the same problem (nohup.out and batch.log grow with "Invalid file descriptor" until the disk gets full and the process crashes).

Thanks for any help on this one.

Aaron Schurger

回答(2 个)

Walter Roberson
Walter Roberson 2012-1-5
Surround your code with a try/catch block (with no action in the catch), and follow it with quit
The try/catch ensures that the quit will be executed even if your program encounters a problem such as the "invalid file descriptor".

Laurence Lurio
Laurence Lurio 2012-6-10
Look at http://www.math.ufl.edu/help/matlab/tec1.1.html I think this is an alternative solution that worked for me (although I had to comment out the DISPLAY stuff)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by