running a linux process in MATLAB
古いコメントを表示
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
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
2013 年 2 月 24 日
Jason Ross
2013 年 2 月 25 日
編集済み: Jason Ross
2013 年 2 月 25 日
Touch can do two things -- one is the thing you mentioned, which is to update the access and modification times of a file. The other thing it can do is create an empty file of the name specified if one doesn't exist already, which is pretty useful. So
touch /tmp/memorylogging
will create a file called "memorylogging" in the directory /tmp
So if you did the following in this order
- Touch the file
- Start the script
The script would run the command until the file was removed, which would make the "while" condition fail, since "-f $file" simply means "does the file exist on disk".
This is a way to implement the control scheme you want, as environment variables aren't communucated between terminal windows.
Manas Savkoor
2013 年 2 月 26 日
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.
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!