编译 C++在远程 Linux 机器上 - “检测到时钟偏差”警告
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
该消息通常表明某些文件的修改时间晚于当前系统时间。由于
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.
通常,当在 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.
安装网络时间协议
在服务器上的 Samba SMB CIFS 共享上运行
make
时,我也遇到过这种情况。持久的解决方案包括在服务器和客户端上安装 ntp 守护进程。
(请注意,这个问题不能通过运行
ntpdate
来解决。这只能暂时解决时差问题,但不会在将来解决。)对于 Ubuntu 和 Debian 衍生系统,只需键入以下行在命令行:
此外,仍然需要在受影响的目录中发出命令
touch *
一次(且仅一次),以一劳永逸地更正文件修改时间。有关
ntp
和ntpdate
之间差异的更多信息,请参阅: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:
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.For more information about the differences between
ntp
andntpdate
, please refer to:简单的解决方案:
一切OK。
欲了解更多信息:
http://embeddedbuzz.blogspot.in/2012 /03/make-warning-clock-skew-detected-your.html
Simple solution:
will do all OK.
For more info:
http://embeddedbuzz.blogspot.in/2012/03/make-warning-clock-skew-detected-your.html
在终端中输入,它将解决问题:
type in the terminal and it will solve the issue:
其他答案已经很好地解释了这个问题,这里不再重复。但有一个尚未列出的解决方案可以解决该问题:只需运行
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 rerunmake
.Having make remove any already compiled files will prevent make from having any files to compare the timestamps of, resolving the warning.
根据 LinuxQuestions.org 上的用户 m9dhatter:
According to user m9dhatter on LinuxQuestions.org:
我过去也遇到过这种情况——因为机器上的时钟出了问题。考虑设置 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.
这通常只是由于主机和客户端计算机之间的时间不匹配造成的。您可以尝试使用 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.
解决方案是运行一个NTP客户端,只需运行如下命令即可
172.16.12.100是ntp服务器
The solution is to run an NTP client , just run the command as below
172.16.12.100 is the ntp server
更换计算机中的手表电池。当主板上的硬币电池需要更换时,我看到了此错误消息。
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.
(以防万一有人降落在这里)
如果您有 sudo 权限,一种选择是同步系统时间
(Just in case anyone lands here)
If you have sudo rights one option is to synchronize the system time
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.
这发生在我身上。这是因为我运行了
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.