0

I have a python code that I will run on a ubuntu machine.It will run in the device for 24/7, 365 Days.

To run the code I will use this command in the terminal:

python3 run.py

How to calculate the CPU and Memory usage of that file when run on the machine?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
null_override
  • 467
  • 3
  • 10
  • 30
  • 1
    Pretty hard to answer because we don't know what the script does. That said, if you run it and on the same machine check out ist usage with htop then it should give you some indication. – JustLudo May 04 '20 at 14:24
  • I used psutil at first. But the pid changes from time to time when seen in Htop.So I can't get a fixed pid for psutil. – null_override May 04 '20 at 14:28
  • 1
    Does this answer your question? [Retrieve CPU usage and memory usage of a single process on Linux](https://stackoverflow.com/questions/1221555/retrieve-cpu-usage-and-memory-usage-of-a-single-process-on-linux) – John Kugelman May 04 '20 at 14:40
  • There are numerous ways to monitor running processes on Linux. You can look at `top` `atop` or `ps` Most of these show CPU and memory usage. – dawg May 04 '20 at 14:42
  • @JohnKugelman not really, but I got a way out. – null_override May 04 '20 at 14:56
  • Care to share your solution? You should have the ability to answer your own question. – JustLudo May 06 '20 at 07:17

0 Answers0