Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 views
in Technique[技术] by (71.8m points)

linux - lsof unable to find the PID of file which gets updated using while loop

Using lsof, I'm unable to get the PID of the file which gets updated using while loop.

┌─[stalin@testbox] - [/tmp] - [Mon Jan 11, 18:50]
└─[$]> sh hostname.sh&
[1] 75634
┌─[stalin@testbox] - [/tmp] - [Mon Jan 11, 18:50]
└─[$]> cat /tmp/hostname.txt
testbox
┌─[stalin@testbox] - [/tmp] - [Mon Jan 11, 18:50]
└─[$]> lsof /tmp/hostname.txt
┌─[stalin@testbox] - [/tmp] - [Mon Jan 11, 18:50]
└─[$]> cat hostname.sh
#!/bin/zsh
while sleep true; do echo $(hostname) > /tmp/hostname.txt; done
┌─[stalin@testbox] - [/tmp] - [Mon Jan 11, 18:50]
└─[$]> uname -a
Darwin testbox 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...