How do you keep track of memory / CPU usage / etc of system commands spawned from R

Say i spawn a system command from an R session:

system("sleep 20")

How can I keep track of the CPU and memory usage of the resulting process (preferably from within an R session)?

Ideal solution would include polling at regular intervals so I can see how CPU / memory usage changes over time

I am running macOS monterey (but a minimally platform specific solution would be ideal)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.