output of top gets truncated to 80 columns when run by cron

top always displays spaces until the last screen column. You just don't realize it when it's printing to the terminal because you can't visually distinguish a line with trailing spaces from a line without trailing space. You'll notice the spaces if you copy-paste with the mouse or in screen.

If you want to get rid of the spaces, just filter them away.

COLUMNS=9999 top -b -c -n 1 | sed 's/  *$//' >>/var/log/toplog/top.log

Whatever you're running top for, there are probably far better monitoring tools available.

Tags:

Cron

Top