running a linux process in MATLAB

조회 수: 2 (최근 30일)
Manas Savkoor
Manas Savkoor 2013년 2월 20일
I need to check memory usage only while running a particular code in MATLAB. I am working on a linux machine
I need to do the below sequence of events in MATLAB
  • matlab commands (4 code initializing);
  • start checking and logging mem usage (Can be done using system command) ;
  • main matlab commands ;
  • stop checking and logging mem usage (Can be done using system command) ;
I tried the following:
Using watch I can keep doing it infinitely. However it requires a manual stop! And I cant predict when it will stop.
I tried creating a shell script with a flag and then tried to update the flag on another terminal. That to didnt work!
flag=0
while [flag == 0]
do
run cmd
done
and in a terminal tried flag=1
Please help! Will there be a mail sent to my mail id? if any one posts a solution?
Regards,
Manants

답변 (1개)

Jason Ross
Jason Ross 2013년 2월 20일
Instead of a variable "flag", why not touch a file
touch /tmp/memorylogging
then in your script you use the existance of the file
#!/bin/bash
file="/tmp/memorylogging"
while [ -f "$file" ]
do
run cmd
done
When you are done you can delete the file and the memory logging will stop.
rm /tmp/memorylogging
  댓글 수: 4
Manas Savkoor
Manas Savkoor 2013년 2월 26일
Ran into a hiccup, the cmd I wanted instead of run cmd is watch cmd which in turn executes the top cmd in batch mode with the output piped into a text file! I cant run the script unless its in background! Then too despite deleting the flag file it still logged the value until I closed MATLAB! Any help?
Jason Ross
Jason Ross 2013년 2월 26일
I think you need to step back and figure out exactly what to do. Draw it out with blocks and arrows, set up a flowchart, etc. Then start with the code and tools you need. It sounds like you are throwing stuff at the wall and hoping it will stick.
The man pages for the various utilites can be very helpful.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by