【问题标题】:How to preserve files original creation date?如何保存文件的原始创建日期?
【发布时间】:2013-12-13 20:33:05
【问题描述】:

我正在使用文件管理器将服务器上的文件从一个目录移动到另一个目录。有没有办法保留文件创建日期/时间(首次添加到服务器时)?有人建议使用 SSH,但我对它不是很熟悉。有人对此有什么好的指导吗?

【问题讨论】:

标签: ssh file-management


【解决方案1】:

scp-p 选项一起使用。

 -p      Preserves modification times, access times, and modes from the original file.

将文件从本地复制到远程服务器的示例命令:

scp -p /home/mylocaldata/test.txt remote.example.com:/home/remote_dir

请注意,这不会保留仅用户和组的权限标志(rwx 等)。

【讨论】:

  • 试试这个网站hypexr.org/linux_scp_help.php scp 带有 linux(大部分时间)。只需尝试命令 shell 并键入 scp。所以命令看起来像这样。假设我需要从 /home/mydata/test.txt 文件传输到目标服务器 x.x.x.x 目录 - /home/test 所以我使用以下命令并保留权限。 scp -p /home/mydata/test.txt x.x.x.x:/home/test
  • 我会假设这是默认设置;以至于我在 ~/.bashrc 中创建了一个别名:alias scp='scp -p' :)
【解决方案2】:

您还可以使用 -t--times 选项通过 ssh 进行 rsync

rsync -P -e ssh -t <source> <destination>

我喜欢使用-P 选项(与--partial --progress 相同),因为如果您在传输过程中途停止(或失败)它不会删除所有文件并报告进度。见man rsync

   -t, --times
          This  tells  rsync  to  transfer modification times along with the
          files and update them on the remote system.  Note that if this op‐
          tion  is  not used, the optimization that excludes files that have
          not been modified cannot be effective; in other words,  a  missing
          -t  or -a will cause the next transfer to behave as if it used -I,
          causing all files to be updated (though rsync’s delta-transfer al‐
          gorithm will make the update fairly efficient if the files haven’t
          actually changed, you’re much better off using -t).

【讨论】:

    【解决方案3】:

    在远程计算机上设置 ssh 服务器后,您可以在 FileZilla 上执行此操作: 传输菜单上有一个保留时间戳选项。

    【讨论】:

      猜你喜欢
      • 2019-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多