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

5 views (last 30 days)

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

Answers (2)

Walter Roberson
Walter Roberson on 5 Jan 2012
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".
  1 Comment
Aaron Schurger
Aaron Schurger on 5 Jan 2012
I should have mentioned that I already did precisely that, but to no avail. Same problem.
Any other suggestions?
Thanks, though.

Sign in to comment.


Laurence Lurio
Laurence Lurio on 10 Jun 2012
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)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!