Aix
SCP 是否鎖定它正在傳輸的文件?
有一種情況,我們有一個應用程序日誌位於 AIX 伺服器上。日誌不斷地從應用程序寫入,我們在 Windows 上有使用者想要查看該文件。他們一直在做的是使用 WinSCP 將文件傳輸到他們的桌面,然後使用文本編輯器打開它。
我認為可能發生的是 scp 在傳輸期間鎖定文件,並且應用程序不再能夠寫入文件。我認為這是日誌文件將在一天中的隨機時間點停止增長的原因。
這可能是怎麼回事?
你為什麼不試試這個。開始 scp’ing 一個大文件,然後
lsof /path/to/file
在 AIX 伺服器上執行並查看 FD 列的內容。從 lsof 手冊頁:
FD is the File Descriptor number of the file or: cwd current working directory; Lnn library references (AIX); err FD information error (see NAME column); jld jail directory (FreeBSD); ltx shared library text (code and data); Mxx hex memory-mapped type number xx. m86 DOS Merge mapped file; mem memory-mapped file; mmap memory-mapped device; pd parent directory; rtd root directory; tr kernel trace file (OpenBSD); txt program text (code and data); v86 VP/ix mapped file; FD is followed by one of these characters, describing the mode under which the file is open: r for read access; w for write access; u for read and write access; space if mode unknown and no lock character follows; `-' if mode unknown and lock character follows. The mode character is followed by one of these lock characters, describing the type of lock applied to the file: N for a Solaris NFS lock of unknown type; r for read lock on part of the file; R for a read lock on the entire file; w for a write lock on part of the file; W for a write lock on the entire file; u for a read and write lock of any length; U for a lock of unknown type; x for an SCO OpenServer Xenix lock on part of the file; X for an SCO OpenServer Xenix lock on the entire file; space if there is no lock. See the LOCKS section for more information on the lock information character. The FD column contents constitutes a single field for parsing in post-processing scripts.
如果你這樣做,至少在 Linux 上,你會看到 FD 列是“3r”,這意味著它有某種讀鎖,但我不確定它前面的 3 是什麼意思。