Limited generic way to replay in slow motion
You can use script
to record htop
, like:
script -O typescript -T typescript.timing -c 'htop -t'
script
will exit just after htop
exits. Alternatively:
script -O typescript -T typescript.timing
puts you in a shell where you can run htop -t
and/or whatever. In this method it's important to exit
the shell; only then script
exits.
After script
exits, you can replay in slow motion:
scriptreplay typescript.timing typescript 0.1
Limitations:
script
records what happens in a terminal session. In your case it does not really record the process tree. It records what htop
prints and it so happens it prints the tree. But if htop
does not show you some process (because it's transient or you're just scrolling through the wrong part of the tree) then scriptreplay
won't show the process either. Consider htop -t -d 1
to make transient processes more likely to be seen. Anyway script
+htop
is by no means a reliable way to audit processes in your OS. I mean you can and will miss out on some processes.
What happens in a terminal session depends on the size of the terminal. Playing it back in a terminal of a different size (especially if smaller in any direction) may cause misalignments, artifacts and such. Resizing the terminal during playback may cause additional artifacts.
If you interrupt scriptreplay
with Ctrl+c then you may need to run reset
or in another way bring your terminal to a sane state.
AFAIK scriptreplay
is not interactive, one cannot even pause it. I have found scriptreplay_ng
, it seems somewhat better in this aspect; but I haven't tested.
atop
can be configured to log system events and play them back, I don't know if it can be set up to achieve what you want though.