How to log processes shown in top by user to a text file

loggingprocesstopusers

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

Best Answer

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.