Is there a magic command in Linux for listing the processes active in the last past n seconds by CPU usage?
To clarify: Process A is launched and it takes 5 seconds to complete, about 5 more seconds go by, magic-command is launched to check processes over the last 20 seconds and its output lists Process A and the amount of CPU usage it had over the previous 20 seconds.
As far as I understand commands like top, ps or mpstat aren't going to inspect resources used before their launch and while find can report which files were used in the past in a scale of minutes or hours, I won't be able to read CPU use from that data.
I believe the only way to do this is to start monitoring resource usage before the events I want to measure take place, am I wrong?