编译 C++在远程 Linux 机器上 - “检测到时钟偏差”警告

发布于 2024-09-25 14:31:19 字数 386 浏览 6 评论 0原文

我使用 PuTTY 从家里连接到大学 Linux 服务器。 我使用 WinSCP 将整个源代码从 Windows 家用计算机上传到 Linux。 然后通过 PuTTY 运行 make 会生成下面一个有趣的警告。

make: warning:  Clock skew detected.  Your build may be incomplete.

生成的二进制文件工作正常,并且在构建过程中似乎没有任何其他意外错误。

我似乎能够通过在上传一些新/替换文件后构建来触发错误(我在本地编辑所有内容,然后上传新版本),所以我想知道这是否与文件修改时间不匹配一样简单?或者还有什么更值得关注的事情?

那么,我应该担心吗?我该如何解决/防止这个问题?

I am connected to university Linux server from home using PuTTY.
I upload entire source code from Windows home computer to Linux using WinSCP.
And then running make via PuTTY generates an interesting warning below.

make: warning:  Clock skew detected.  Your build may be incomplete.

The resulting binary works correctly, and there doesn't seem to be any other unexpected errors in the build process.

I seem to be able to trigger the error by building after uploading some new / replacement files (I edit everything locally then upload the new version), so I'm wondering if it's something just as simple as mismatched file modification times? Or something more concerning?

So, should I be worried? How do I fix/prevent this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

自找没趣 2024-10-02 14:31:20

该消息通常表明某些文件的修改时间晚于当前系统时间。由于 make 在执行增量构建时通过检查源文件是否比其目标文件最近被修改来决定编译哪些文件,因此这种情况可能会导致构建不必要的文件,或更糟糕的是,构建必要的文件被建造。

但是,如果您是从头开始构建(而不是进行增量构建),您可能会忽略此警告而不会产生任何后果。

That message is usually an indication that some of your files have modification times later than the current system time. Since make decides which files to compile when performing an incremental build by checking if a source files has been modified more recently than its object file, this situation can cause unnecessary files to be built, or worse, necessary files to not be built.

However, if you are building from scratch (not doing an incremental build) you can likely ignore this warning without consequence.

情深缘浅 2024-10-02 14:31:20

通常,当在 NFS 安装目录中构建时会发生这种情况,并且客户端和 NFS 服务器上的时钟不同步。

解决方案是在 NFS 服务器和所有客户端上运行 NTP 客户端。

Typically this occurs when building in a NFS mounted directory, and the clocks on the client and the NFS server are out of sync.

The solution is to run an NTP client on both the NFS server and all clients.

寄离 2024-10-02 14:31:20

安装网络时间协议

在服务器上的 Samba SMB CIFS 共享上运行 make 时,我也遇到过这种情况。
持久的解决方案包括在服务器和客户端上安装 ntp 守护进程。
(请注意,这个问题不能通过运行 ntpdate 来解决。这只能暂时解决时差问题,但不会在将来解决。)

对于 Ubuntu 和 Debian 衍生系统,只需键入以下行在命令行:

$ sudo apt install ntp

此外,仍然需要在受影响的目录中发出命令 touch * 一次(且仅一次),以一劳永逸地更正文件修改时间。

$ touch *

有关 ntpntpdate 之间差异的更多信息,请参阅:

Install the Network Time Protocol

This also happened to me when running make on a Samba SMB CIFS share on a server.
A durable solution consists in installing the ntp daemon on both the server and the client.
(Please, note that this problem is not solved by running ntpdate. This would resolve the time difference only temporarily, but not in the future.)

For Ubuntu and Debian-derived systems, simply type the following line at the command line:

$ sudo apt install ntp

Moreover, one will still need to issue the command touch * once (and only once) in the affected directory to correct the file modification times once and for all.

$ touch *

For more information about the differences between ntp and ntpdate, please refer to:

请恋爱 2024-10-02 14:31:20

简单的解决方案:

# touch filename

一切OK。

欲了解更多信息:
http://embeddedbuzz.blogspot.in/2012 /03/make-warning-clock-skew-detected-your.html

Simple solution:

# touch filename

will do all OK.

For more info:
http://embeddedbuzz.blogspot.in/2012/03/make-warning-clock-skew-detected-your.html

小帐篷 2024-10-02 14:31:20

在终端中输入,它将解决问题:

find . -type f | xargs -n 5 touch

make clean

clean

type in the terminal and it will solve the issue:

find . -type f | xargs -n 5 touch

make clean

clean
你的呼吸 2024-10-02 14:31:20

其他答案已经很好地解释了这个问题,这里不再重复。但有一个尚未列出的解决方案可以解决该问题:只需运行 make clean,然后重新运行 make

让 make 删除任何已编译的文件将阻止 make 比较任何文件的时间戳,从而解决警告。

The other answers here do a good job of explaining the issue, so I won't repeat that here. But there is one solution that can resolve it that isn't listed yet: simply run make clean, then rerun make.

Having make remove any already compiled files will prevent make from having any files to compare the timestamps of, resolving the warning.

貪欢 2024-10-02 14:31:20

根据 LinuxQuestions.org 上的用户 m9dhatter

“make”使用文件的时间戳来确定文件是否
它正在尝试编译是旧的还是新的。如果你的时钟坏了,编译可能会出现问题。

如果您尝试在时钟时间提前几分钟的另一台计算机上修改文件并将它们传输到您的计算机,然后尝试编译,可能会发出警告,指出该文件是从未来修改的。时钟可能会倾斜或有类似的效果(不太记得了)。您可以直接 ls 到有问题的文件并执行以下操作:

#touch <违规文件的文件名>

According to user m9dhatter on LinuxQuestions.org:

"make" uses the time stamp of the file to determine if the file
it is trying to compile is old or new. if your clock is bonked, it may have problems compiling.

if you try to modify files at another machine with a clock time ahead by a few minutes and transfer them to your machine and then try to compile it may cough up a warning that says the file was modified from the future. clock may be skewed or something to that effect ( cant really remember ). you could just ls to the offending file and do this:

#touch <filename of offending file>

懒的傷心 2024-10-02 14:31:20

我过去也遇到过这种情况——因为机器上的时钟出了问题。考虑设置 NTP,以便所有计算机都有相同的时间。

I have had this in the past - due to the clocks being out on the machines. Consider setting up NTP so that all machines have the same time.

_畞蕅 2024-10-02 14:31:20

这通常只是由于主机和客户端计算机之间的时间不匹配造成的。您可以尝试使用 ntp 同步计算机上的时间。

This is usually simply due to mismatching times between your host and client machines. You can try to synchronize the times on your machines using ntp.

尛丟丟 2024-10-02 14:31:20

解决方案是运行一个NTP客户端,只需运行如下命令即可

#ntpdate 172.16.12.100

172.16.12.100是ntp服务器

The solution is to run an NTP client , just run the command as below

#ntpdate 172.16.12.100

172.16.12.100 is the ntp server

岁月无声 2024-10-02 14:31:20

更换计算机中的手表电池。当主板上的硬币电池需要更换时,我看到了此错误消息。

Replace the watch battery in your computer. I have seen this error message when the coin looking battery on the motherboard was in need of replacement.

层林尽染 2024-10-02 14:31:20

(以防万一有人降落在这里)
如果您有 sudo 权限,一种选择是同步系统时间

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

(Just in case anyone lands here)
If you have sudo rights one option is to synchronize the system time

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
川水往事 2024-10-02 14:31:20

Make 检查编译结果(例如 somefile.o)是否比源文件(例如 somefile.c)旧。上面的警告意味着文件的时间戳有些奇怪。大学服务器的系统时钟可能与您的时钟不同,例如您在下午 1 点推送修改日期为下午 2 点的文件。您可以通过键入日期在控制台上查看时间。

Make checks if the result of the compilation, e.g. somefile.o, is older than the source, e.g. somefile.c. The warning above means that something about the timestaps of the files is strange. Probably the system clocks of the University server differs from your clock and you e.g. push at 1 pm a file with modification date 2 pm. You can see the time at the console by typing date.

青柠芒果 2024-10-02 14:31:20

这发生在我身上。这是因为我运行了 make -j 4 并且一些作业没有按顺序完成。使用 -j 选项时应该会出现此警告。

This happened to me. It's because I ran make -j 4 and some jobs finished out of order. This warning should be expected when using the -j option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文