*/1 * * * * COLUMNS=512 top -b -n 1 >> /tmp/top.logOption b stands for batch mode. Finally "n 1" means top to end after a single iteration/refresh.
Saturday, December 14, 2013
top and cron - Log all commands being run every minute
To troubleshoot what is going on in Unix and Linux systems your first step is usually top. You can run it in two modes: interactive and batch mode. In batch mode the output can be piped to any other command making it ideal to leave it croned in a server to later on analyze what is going on there: