I'm running some commands on the shell from PHP (such as ImageMagick's "convert" utility, among others), and I'd like to track the peak memory usage of those processes. PHP has a pretty simple way of getting peak memory usage of the PHP script itself, and I'd like to augment that data with information about external scripts run by the PHP script.
Is there some way to do that?