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

How to run matlab in background on a linux server?

2,107 views
Skip to first unread message

Yuheng

unread,
Jan 3, 2011, 9:34:04 PM1/3/11
to
I tried a command like this:

nohup matlab linux_try.m 1>std.out 2>err.out &

there is only one line in the file linux_try.m, which is

a = magic(5)

but in std.out there are a lot of 'Warning: Error reading character from command line', and in err.out there are a lot of 'Bad file descriptor'.

Can anybody help me? Thanks a lot

Steven_Lord

unread,
Jan 4, 2011, 11:07:27 AM1/4/11
to

"Yuheng " <e2_7...@tom.com> wrote in message
news:ifu0us$i02$1...@fred.mathworks.com...

Try invoking MATLAB with the -r startup option.

http://www.mathworks.com/help/techdoc/matlab_env/f8-4994.html

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlab.wikia.com/wiki/FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Yuheng

unread,
Jan 5, 2011, 1:49:05 AM1/5/11
to
"Steven_Lord" <sl...@mathworks.com> wrote in message <ifvgjv$1du$1...@fred.mathworks.com>...

Thank you for your suggestion, and the link is very helpful.

With an 'exit' added to the end of the script file, the following command works very well

nohup matlab -r "linux_try" -logfile "data.log" 1>stdout.out 2>err.out &

The only small problem is, if the script is not ended with an 'exit'. Matlab will continuously output error messages such as 'Error reading character from command line' and 'Bad file descriptor' in 'data.log', 'stdout.out' and 'err.out', until the process is killed. Do you have any idea of the reason?

At last, I want to thank you again for all your help!

Siyanda Nazo

unread,
Apr 19, 2011, 3:57:02 AM4/19/11
to
Hi all

I am also trying to run a matlab file on the linux command line and have encountered the same problems. The line I enter on the command line is:

nohup matlab -nojvm -r "My_script" > My_script_out.txt&

I have placed the exit command at the end of the file 'My_script' but Matlab seems to go into a never ending loop and prints 'bad file descriptor' in the output file when it finishes executing the matlab script. Has anyone encountered this problem and if so, what is the solution?
"Yuheng" wrote in message <ig1491$5tu$1...@fred.mathworks.com>...

Steven_Lord

unread,
Apr 19, 2011, 9:19:08 AM4/19/11
to

"Siyanda Nazo" <siyand...@gmail.com> wrote in message
news:iojf8e$1gs$1...@fred.mathworks.com...


> Hi all
>
> I am also trying to run a matlab file on the linux command line and have
> encountered the same problems. The line I enter on the command line is:
>
> nohup matlab -nojvm -r "My_script" > My_script_out.txt&
>
> I have placed the exit command at the end of the file 'My_script' but
> Matlab seems to go into a never ending loop and prints 'bad file
> descriptor' in the output file when it finishes executing the matlab
> script. Has anyone encountered this problem and if so, what is the
> solution?

I'm not certain -- you should contact Technical Support for help determining
the cause of this behavior.

--
Steve Lord
sl...@mathworks.com

Anna

unread,
Jan 30, 2012, 3:39:10 AM1/30/12
to
Hi!
I have solved this issure by typing:

nohup matlab -nojvm -r name_of_your_script_without_extension -logfile name_of_logfile.out </dev/null &

Cheers,
Anna

"Steven_Lord" <sl...@mathworks.com> wrote in message <iok23p$amv$1...@fred.mathworks.com>...

isabel

unread,
May 3, 2012, 6:01:08 PM5/3/12
to
"Yuheng" wrote in message <ifu0us$i02$1...@fred.mathworks.com>...
you missed the < to pass the input argument (file name)
0 new messages