Thread Subject:
How to run matlab in background on a linux server?

Subject: How to run matlab in background on a linux server?

From: Yuheng

Date: 4 Jan, 2011 02:34:04

Message: 1 of 7

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

Subject: How to run matlab in background on a linux server?

From: Steven_Lord

Date: 4 Jan, 2011 16:07:27

Message: 2 of 7



"Yuheng " <e2_71828@tom.com> wrote in message
news:ifu0us$i02$1@fred.mathworks.com...
> 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

Try invoking MATLAB with the -r startup option.

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

--
Steve Lord
slord@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

Subject: How to run matlab in background on a linux server?

From: Yuheng

Date: 5 Jan, 2011 06:49:05

Message: 3 of 7

"Steven_Lord" <slord@mathworks.com> wrote in message <ifvgjv$1du$1@fred.mathworks.com>...
>
>
> "Yuheng " <e2_71828@tom.com> wrote in message
> news:ifu0us$i02$1@fred.mathworks.com...
> > 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
>
> Try invoking MATLAB with the -r startup option.
>
> http://www.mathworks.com/help/techdoc/matlab_env/f8-4994.html
>
> --
> Steve Lord
> slord@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

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!

Subject: How to run matlab in background on a linux server?

From: Siyanda Nazo

Date: 19 Apr, 2011 07:57:02

Message: 4 of 7

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" <slord@mathworks.com> wrote in message <ifvgjv$1du$1@fred.mathworks.com>...
> >
> >
> > "Yuheng " <e2_71828@tom.com> wrote in message
> > news:ifu0us$i02$1@fred.mathworks.com...
> > > 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
> >
> > Try invoking MATLAB with the -r startup option.
> >
> > http://www.mathworks.com/help/techdoc/matlab_env/f8-4994.html
> >
> > --
> > Steve Lord
> > slord@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
>
> 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!

Subject: How to run matlab in background on a linux server?

From: Steven_Lord

Date: 19 Apr, 2011 13:19:08

Message: 5 of 7



"Siyanda Nazo" <siyanda.nazo@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
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: How to run matlab in background on a linux server?

From: Anna

Date: 30 Jan, 2012 08:39:10

Message: 6 of 7

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" <slord@mathworks.com> wrote in message <iok23p$amv$1@fred.mathworks.com>...
>
>
> "Siyanda Nazo" <siyanda.nazo@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
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Subject: How to run matlab in background on a linux server?

From: isabel

Date: 3 May, 2012 22:01:08

Message: 7 of 7

"Yuheng" wrote in message <ifu0us$i02$1@fred.mathworks.com>...
> 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

you missed the < to pass the input argument (file name)
nohup matlab < linux_try.m 1> std.out 2> err.out &

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
nohup Yuheng 3 Jan, 2011 21:39:07
backgroud Yuheng 3 Jan, 2011 21:39:07
linux Yuheng 3 Jan, 2011 21:39:06
rssFeed for this Thread

Contact us