2

Do you know How to monitor memory usage of a single process?

I want to get Memory usage over a given time frame including maximum usage and average usage.

Don't tell me use top -p PID, since I cannot stare the screen for hours to check the maximum memory usage.

heemayl
  • 91,753
Shicheng Guo
  • 161
  • 2
  • 8
  • Have you looked at this: http://askubuntu.com/questions/56266/how-to-log-memory-and-cpu-usage-of-an-application – Marc Jan 13 '16 at 02:40
  • Don't have my linux box avail. atm so can't be specific but look at pidstatwhich is in the sysstat package. Run man pidstat to see options & at bottom some example commands. You can output to a log & if desired just minimize the terminal for longer term monitoring – doug Jan 13 '16 at 03:29

1 Answers1

2

Install sysstat package

Read man pidstat, look at option & for example commands go to bottom of man page.

Ex. of nautilus, current id here as reported by ps is 2286, generating 120 reports 60 secs apart, outputting to a log in home folder

Get process id you want to track, many ways, a couple below - (start process/app

find in list

ps axu

If you know the name then this works fine, current example of nautilus

ps axu |grep nautilus |grep -v grep

Then in a terminal, (replacing your process # after -p

pidstat -r -p 2286 60 120 > naut-mem.log

If desired just minimize terminal while pidstat is running

If you plan on outputting to same log file several times & want it appended to then use >> instead of > in command

doug
  • 17,026