Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to log the amount of memory used by each process in linux? One of our servers has a memory usage spike that brings down the machine from time to time and the logging would really help us find the root cause.

share|improve this question

If your needs aren't very complex perhaps you could make do with ps and a while loop:

while true; do date; ps auxw --sort rss | tail -n 10; echo; sleep 60; done >> logfile

This logs the top ten processes (by memory use) every minute.

share|improve this answer

The cleanest solution would be to put in a cron job which does something similar to

ps auxww | logger -p -t ps 

This would log ps output through your logging daemon to the local0 facility (can be changed to whatever you want)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.