3

I need to log all processes (including the amount of CPU usage used, the time it was running for, etc...) to a txt file; preferably one entry per line as it appears in top.

The user appears to be running an abusive process via cron however I want to monitor it and be sure of the usage it is actually using on the server so to be sure and also so I have proof (with timestamps preferably too).

Cheers, K

2 Answers2

4

Try this:

top -b -d <interval-in-secs> -u <username> >> /tmp/top.log &

This will write every $INTERVAL all processes run by the specified user to a logfile.

weeheavy
  • 4,039
  • 1
  • 27
  • 41
1
top -b gives you the ability to redirect top's output to a file. 

Another way to play around with logs is to add splunk and its linux application which monitors everything.

But in your case, the best solution is to watch cron jobs of every user and mark the abusive.

Or use ulimit and when he exceeds a threshold to give you a report.

By what mean is it abussive ?

Nikolaidis Fotis
  • 1,994
  • 11
  • 13