服务器上 tar 解压缩报错 time stamp xxx is xxx s in the future

文章目录

    用 shell 脚本自动打包本地的前端目录,然后到 ubuntu 服务器上解压。

    tar xvzf some.tar.gz
    

    但是报了一堆错误

    tar: frontend/dist/region/index.html: time stamp 2024-12-10 16:03:59 is 19.628258333 s in the future
    tar: frontend/dist/region: time stamp 2024-12-10 16:03:59 is 19.628150028 s in the future
    

    然后,后面的 shell 脚本就不执行了。🥲

    确认了一下:

    • ubuntu 服务器上的时间是正确的,而且有自动同步 NTP 的计划任务;
    • 问题出在本地的 windows 11 的系统时间上,本地时间比服务器时间快了近 1 分钟。。。

    而且上次同步还是两个月前。。。

    解决方法

    tar xvzf some.tar.gz --warning=no-timestamp
    

    再就是点击了系统时间同步按钮。但是这样还是麻烦,得找找有没有自动同步的方法。

    man tar

    查看一下 tar 命令的说明,可以看到 warning 参数支持一堆参数,其中

     timestamp
            "%s: implausibly old time stamp %s"
            "%s: time stamp %s is %s s in the future"
    

    参考

    https://unix.stackexchange.com/questions/14528/prevent-showing-time-stamp-message-when-running-tar-xzf

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式