dk13
dk13

Reputation: 1501

Is it possible to watch the ongoing cpu and memory usage of a running C++ app on a server linux distro?

I have developed a c++ app that runs on debian jessie server. Since I'm quite new in linux distros and specially the server ones that provide only terminal, I 'd like to find out if there is a way to watch the %CPU and %MEM on the same time that the c++ app runs. I tried to run

./C++_APP & ps -aux | grep .C++_APP

but ps ran only at the beginning. Is this possible somehow either with ps or with another command?

Upvotes: 0

Views: 63

Answers (3)

Laurent G
Laurent G

Reputation: 397

You can use/install htop. Set filter to match your executable name.

Upvotes: 1

Anty
Anty

Reputation: 1516

You may try that:

./C++_APP & wait && PID=`pidof -s -x C++_APP` && top -b -p $PID

It will display stats every second. To break CTRL+C

To kill your app type than

kill $PID

Upvotes: 0

rbaleksandar
rbaleksandar

Reputation: 9681

Use watch. You can pass your ps (along with its arguments) to it. If you don't run your application as a background process you will have to use a second terminal session or pipe the results to a file that you can look at later on.

Upvotes: 1

Related Questions