プロセスごとのCPU使用率をログに取るには

プロセスごとのCPU使用率はtopコマンドで画面に表示できる。だけど、topコマンドは端末の画面の大きさに合わせて自動的に結果をカットしてくれる(レコードが固定長になる)ので、ログを取るのには向いていない。
きれいにログを取るには、psコマンドを使う。

while true;
  do ps auxww --sort=-pcpu | sed -e "s/^/`date +%T` /" >> hoge.log;
  sleep 60;
done;

こんな感じで取れる。

06:41:29 USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
06:41:29 root      4255  0.1  1.9  26872 20332 tty7     Ss+  05:52   0:04 /usr/bin/Xorg :0 -br -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7
06:41:29 root      3761  0.1  0.3  10348  3112 ?        Ss   05:52   0:03 cupsd
06:41:29 68        3991  0.0  0.4   6412  4496 ?        Ss   05:52   0:01 hald
06:41:29 hide      5213  0.0  1.5  63916 15740 ?        Sl   05:55   0:01 gnome-terminal
06:41:29 root      4075  0.0  0.0   1968   672 ?        S    05:52   0:01 hald-addon-storage: polling /dev/hda