Skip to content

Instantly share code, notes, and snippets.

@ysugimoto
Created January 8, 2014 14:45
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 ysugimoto/8317861 to your computer and use it in GitHub Desktop.
Save ysugimoto/8317861 to your computer and use it in GitHub Desktop.
現在時刻のずれチェックするやつ
#!/usr/bin/env ruby
require 'date'
require 'json'
require 'net/http'
response = Net::HTTP.get URI('http://ntp-a1.nict.go.jp/cgi-bin/json')
json = JSON.parse(response)
diff = json['st'] - Time.now.to_i
if ( diff < -50 || diff > 50 )
p '現在時刻がずれています'
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment