I have 30 instances of a process running on a server and want to log open files for each process for analysis.
I ran the following command:
* ps auw
You can use xargs -L1 lsof -p to run lsof once per pid.
xargs -L1 lsof -p
lsof
Even better: use lsof -c to list all open files from commands matching a specific pattern:
lsof -c
lsof -c bas # list all processes with commands starting with 'bas' lsof -c '/ash$/x' # list all commands ending with 'ash' (regexp syntax)