How to create a tar file that omits timestamps for its contents?

后端 未结 3 1739
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 05:42

Is there a way to create a .tar file that omits the values of atime/ctime/mtime for its files/directories?

Why do we want to do this?

We have a st

3条回答
  •  余生分开走
    2021-02-05 05:54

    GNU tar has a --mtime argument, which can be used to store a fixed date in the archive rather than a file's actual mtime:

    tar --mtime='1970-01-01' input ...
    

    When compressing a tarball with gzip, it's also necessary to specify -n to prevent name and timestamp of the tar archive from being stored:

    tar --mtime='1970-01-01' input ... | gzip -n >input.tar.gz
    

提交回复
热议问题