My roommate's computer's clock has been broken since we first installed Linux on it. It was never a big deal, but it's been annoying me for a long time.

Recently, my laptop started to have a similar problem. A friend had used Windows on it, and so the clock was set to local time instead of UTC. Fixing that finally gave me the inspiration to fix my roommate's computer as well.

I had NTP running, so after about 11 minutes of being on, my laptop's time would fix itself. The problem was that the time wasn't being saved. Apparently Arch Linux added a hwclock daemon since I first installed it, so I just needed to add that to my daemons array and the problem was solved.

Fixing that on the roommate's computer didn't solve the problem though, and further investigation revealed that the clock's drivers weren't working. His motherboard has poor Linux support, so it was surprising, and unfortunately there's no much I can do about that. What I can do is use NTP.

Setting up NTP put his computer in the same situation as mine: The clock was off until NTP fixed it, which sometimes took a long time. Luckily, there's a program to set the date immediately, called ntpdate. The only problem was that I couldn't just put it in rc.local; it needed to run after the network was up.

NetworkManager has a dispatcher, which will run all of the scripts in a directory (/etc/NetworkManager/dispatcher.d) whenever a network interface starts or stops. Given that, it was easy to set up a solution:

# File: /etc/NetworkManager/dispatcher.d/ntp

# This file tells us if the script has already
# been run. It must be in tmpfs, so it will be
# deleted when the computer shuts down.

servers=" \ \ \"

# The first time a network interface goes up,
# update the time using NTP.
if [ "$2" = "up" ]; then
        if [ ! -f $tmpfile ]; then
                ntpdate $servers
                touch $tmpfile

With this, every time his machine starts up, the time is off, and then about 30 seconds later it's correct (about the amount of time it takes to type your password on the login screen).

Problem solved.. ish.