0

I am trying to run a small shell script .sh and i wanted to see what files it's going to open using lsof. how do i execute shell script and attach its PID to lsof?

I tried following but didn't work:

lsof -p $(./foo.sh)

and

lsof -c ./foo.sh
2

wanted to see what files it's going to open

strace -f -e open bash ./foo.sh

Or you can run your shell in the backgroud and immediately run lsof

$ ./short-lived-script.sh & lsof -p $!
  • i want to see that in lsof i already tried strace. I want that in lsof – Satish Mar 21 '16 at 21:18
  • Is your script long running ? – Sergei Kurenkov Mar 21 '16 at 21:19
  • No, its short run, 3 or 4 second – Satish Mar 21 '16 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.