Compiling C++ on remote Linux machine - "clock skew detected" warning

LinuxMakefile

Linux Problem Overview


I'm connected to my university's small Linux cluster via PuTTY and WinSCP, transferring files using the latter and compiling and running them with the former. My work so far has been performed in the university's labs, but today I have been doing some work at home that generated an interesting warning.

I uploaded an entire folder of stuff and, upon running the make command, I get this as the last line of output:

>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?

Linux Solutions


Solution 1 - Linux

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.

Solution 2 - Linux

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.

Solution 3 - Linux

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:

Solution 4 - Linux

Simple solution:

# touch filename

will do all OK.

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

Solution 5 - Linux

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.

Solution 6 - Linux

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>

Solution 7 - Linux

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.

Solution 8 - Linux

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.

Solution 9 - Linux

type in the terminal and it will solve the issue:

find . -type f | xargs -n 5 touch

make clean

clean

Solution 10 - Linux

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

Solution 11 - Linux

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.

Solution 12 - Linux

(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"

Solution 13 - Linux

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.

Solution 14 - Linux

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDMA57361View Question on Stackoverflow
Solution 1 - LinuxTyler McHenryView Answer on Stackoverflow
Solution 2 - LinuxjannebView Answer on Stackoverflow
Solution 3 - LinuxSerge StroobandtView Answer on Stackoverflow
Solution 4 - LinuxBrijesh ValeraView Answer on Stackoverflow
Solution 5 - LinuxskrrgwasmeView Answer on Stackoverflow
Solution 6 - Linuxz -View Answer on Stackoverflow
Solution 7 - LinuxEd HealView Answer on Stackoverflow
Solution 8 - LinuxSoo Wei TanView Answer on Stackoverflow
Solution 9 - LinuxKhanView Answer on Stackoverflow
Solution 10 - LinuxSurjitView Answer on Stackoverflow
Solution 11 - LinuxBlushONineView Answer on Stackoverflow
Solution 12 - LinuxObviousChildView Answer on Stackoverflow
Solution 13 - LinuxfschmittView Answer on Stackoverflow
Solution 14 - LinuxkilojoulesView Answer on Stackoverflow