Originally Posted by homey
You could grab the correct time off a network clock and update the hardware clock in this one liner...
su - -c "ntpdate ntp.nasa.gov ; hwclock --systohc"
BZZZZZZZZZZZZZZZZZZZZZZZZZZZ. Incorrect answer. Actually not incorrect, but not wholly correct either.
While the one-liner will work, for home systems you should NEVER point to a specific time server, particularly tier 1 systems like NASA or NIST. Those things get pounded, and if it keeps up, access is going to be restricted.
The correct way to use time servers is through the pool system
. This points you at a set of servers and the load is distributed so no one server gets swamped. It is the polite way to keep your clocks synchronized.
So the correct answer here is:
su - -c "ntpdate 0.us.pool.ntp.org ; hwclock --systohc"
Of course you can adjust the pool server to reflect the country you live in.