I have a small program which I compiled myself. It’s CPU intensive, so I want to watch the CPU usage when it’s working.
However, when I run ./myprog
, I can’t run top
immediately and sequentially.
I have a small program which I compiled myself. It’s CPU intensive, so I want to watch the CPU usage when it’s working.
However, when I run ./myprog
, I can’t run top
immediately and sequentially.
Another suggestion: open a new tab on your terminal emulator.
You can run it in background:
To resume it from background use the fg command, for example:
To see all jobs in background, run the jobs command:
You can:
send it in background (see @Panta's answer) if you can; this is not possible or messy if the program need to do input/output on the console;
use another virtual console (by default, you have 6); you can switch with
ctrl
-alt
-F1
toF6
and login;Use a terminal multiplexer like tmux or screen.
pidstat might be useful for you, I think.
Since your program is so CPU hungry, run top first in one terminal screen and
./myprog
in a second terminal screen (or tab as mentioned). Since top is already running at this point./myprog
won't interfere with it starting up.