Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

makefile

People also ask

What is clock skew detected?

gmake: warning: Clock skew detected. Your build may be incomplete. This warning occurs when the synchronization of the server and clients is off. This warning denotes a system / NFS problem, and is not related to ClearCase.


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.


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.


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:

  • Time Synchronisation with NTP
  • How To Set Up Time Synchronization on Ubuntu 16.04

Simple solution:

# touch filename

will do all OK.

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


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.


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>