MATLAB running in Linux background

45 views (last 30 days)
Yigithan Mehmet Kose
Yigithan Mehmet Kose on 16 Jan 2024
Commented: Damian Pietrus on 16 Jan 2024
Hello,
I am trying to run a MATLAB code remotely in a Linux machine. The code have to keep running even if I get disconnected. I looked up other threads and tried this:
nohup matlab -nodisplay -nosplash -r "run('opt_main.m'); exit" > output.log 2>&1 &
where opt_main is my script. When I do this, I get such messages in the terminal:
[2] 75698
or
[4] 76510
Then I get a very long error message, which includes expressions as such:
corrupted double-linked list
corrupted unsorted chunks
Please note that I include parallel computing. Can anyone help me?

Answers (1)

Hassaan
Hassaan on 16 Jan 2024
The error messages you're encountering, such as "corrupted double-linked list" and "corrupted unsorted chunks," suggest memory-related issues. Running MATLAB in the background with nohup on a remote machine might lead to problems with the X11 display.
To run MATLAB in the background and prevent issues with the X11 display, you can use the matlab -batch option instead. Also, it's a good practice to use the -singleCompThread option when running MATLAB remotely to avoid potential parallel computing issues.
nohup matlab -nodisplay -nosplash -singleCompThread -batch "run('opt_main.m'); exit" > output.log 2>&1 &
Explanation of changes:
  • -batch is used instead of invoking the MATLAB command prompt directly.
  • -singleCompThread is added to disable multithreading, which can sometimes cause issues when MATLAB is run in the background.
This command should help in running MATLAB in the background on your Linux machine without encountering the X11 display-related issues. Additionally, make sure that your MATLAB script (opt_main.m) is set up to handle any necessary dependencies and paths correctly when running in batch mode.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.
  3 Comments
Hassaan
Hassaan on 16 Jan 2024
You can try.
------------------------------------------------------------------------------------------------------------------------------------------------ If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback. Professional Interests Technical Services and Consulting Embedded Systems | Firmware Developement | Simulations Electrical and Electronics Engineering Feel free to contact me.
Damian Pietrus
Damian Pietrus on 16 Jan 2024
Parallel workers are single-threaded by default, so using -singleCompThread will still allow you to to explicitly start up a parallel pool and use parallel processing.
If you have a lot of serial code that uses multithreaded libraries such as fft outside of your parallel code, then you may wish to leave off the -singleCompThread flag.

Sign in to comment.

Categories

Find more on Startup and Shutdown 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!