Skip to content

Instantly share code, notes, and snippets.

@drakkhen
Created May 3, 2013 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakkhen/5507066 to your computer and use it in GitHub Desktop.
Save drakkhen/5507066 to your computer and use it in GitHub Desktop.
Force capistrano to check your local systems time drift before deploying
before "deploy", "check_time"
task :check_time do
offset = `ntpdate -q ntp.ubuntu.com | tail -n 1 | awk -Foffset\ '{print $2}' | awk '{print $1}'`.strip
if offset.to_f > 1.0
puts "Your clock is off by #{offset} seconds! Type `sudo ntpdate ntp.ubuntu.com` and try again."
exit(1)
end
end

If your local time is way off and you deploy with capistrano bad things can happen.

This task checks your local time before deploying. If it's > 1 second off it halts the deployment, tells you about the problem, and offers an easy way to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment