Ubuntu – Find out which file a process is writing when PID changes all the time

chromiumdisk-usage

Using tools like iotop one can monitor the i/o of individual processes which is fine, but you do not find out which directory a process writes into.
If the PID would always be the same that would not be a problem, one could strace or something else to find out which files are affected, or possibly

lsof +p <PID>  

But I noticed chromium does some heavy disk writes when I open a video, despite the fact that I already put many directories associated with chromium on a tmpfs.
Now I would like to find out which directories it writes to in the instant iotop shows the high i/o usage.
Chromium does change the PID all the time, which makes this even more complex.

Best Answer

We may use pidof to determine the PID(s) of an application for iotop Install iotop

sudo iotop -p $(pidof chromium-browser | sed -r 's/[ ]+/ -p /g')

For any other command needing a different separator of the PID list replace the separator in the sed command, e.g.

top -p $(pidof chromium-browser | sed -r 's/[ ]+/,/g')
sudo lsof -p $(pidof chromium-browser | sed -r 's/[ ]+/,/g')
Related Question