SCP是否锁定正在传输的文件?


8

遇到这样的情况,我们的应用程序日志位于AIX服务器上。该日志不断从应用程序写入,并且我们有Windows用户希望查看该文件。他们一直在使用WinSCP将文件传输到桌面,然后使用文本编辑器将其打开。

我认为可能正在发生的事情是scp在传输期间锁定了文件,并且应用程序不再能够写入该文件。我认为这是因为日志文件将在一天中的任意时间停止增长。

那可能是怎么回事?


我认为aix欢迎使用标签。
Cristian Ciupitu

Answers:


8

你为什么不试试这个。开始截取一个大文件,然后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意味着什么。


仅供参考,是的,它将读取锁定置于文件上!谢谢!
2010年

哦,实际上,小r表示仅锁定文件的一部分,那么scp可能不是问题所在……
ThaDon 2010年

1
没错,小r表示它是字节锁。因此,从理论上讲,它只是锁定当前正在发送的部分。但是,如果您阅读有关锁定的lsof手册页,则它也表示在某些情况下它可能无法准确报告锁定。您可能想在有一个大文本文件的地方设置一个实验...开始对其进行筛选,然后执行类似echo“ blah blah blah” >>文本文件的操作。如果成功将其添加到文件末尾,那么我会说lsof报告的内容是正确的。
3dinfluence 2010年

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.