commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
using -u is better for standardizing date output and timezones, for servers in different timezones.
Neat idea! This variation works on FreeBSD.
Shorter, easier to remember version of cmd#7636
NTP is better, but there are situations where it can't be used. In those cases, you can do this to sync the local time to a server.
If you are stuck behind a firewall and want to synchronize time with another server but you do not want to port forward NTP (which uses UDP) then this command is handy. It gets the time from a server and sets the local time. It is not that accurate but I can live with a second or so drift.