2

Id like to measure the cpu usage during the execution of a command. If I type $ cp BigFile Location Id like to see how much this process used cpu power

6
  • time cp Location, will give you processing time, what metric are you after? Commented Jun 30, 2020 at 11:34
  • @LawrenceCherone but i need the cpu usage in percent Commented Jun 30, 2020 at 11:35
  • 1
    You might be interested in this post: unix.stackexchange.com/questions/554/… Commented Jun 30, 2020 at 11:36
  • percent is a rolling average :/ if it takes 20mins how would 15% make sense, some details on conversion from time to utilisation here Commented Jun 30, 2020 at 11:36
  • I need a min and average and a high value Commented Jun 30, 2020 at 11:38

3 Answers 3

3

I recently found a tool which measures time, cpu usage, memory usage all at once. Its called /usr/bin/time and should be installed via apt

Sign up to request clarification or add additional context in comments.

Comments

1

htop is a graphical solution in the shell - maybe this one helps

There you can search for it.

Comments

0

top command will show you memory and CPU usage,

you can pipe with grep

top | grep chrome  # for google chrome cpu and mem usage for and example

7 Comments

that works but how do i check the usage from a command within a script and store it into a file or smth
cant you use PID ?
but how does the script know when to stop monitoring
how about giving approximate time loop : stackoverflow.com/questions/11176284/…
would work but for a script... its not the most elegant way
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.