Accurate time keeping on an Apple Mac running macOS Mojave

When running data modes such as the very popular FT8, it’s important to keep your computer clock accurate because if it’s more than a couple of seconds out then you won’t be able to decode anyone, they won’t be able to decode you and you won’t make any QSOs.  There are a number of utilities for Windows to keep the clock accurate and it’s fairly essential you use one of them.

Last year I wrote a piece about keeping your clock accurate in macOS which worked perfectly well in High Sierra but no longer works using macOS Mojave because the command I recommended has been removed from the operating system.

I’ve done some investigation and have found another command which works just as well.  I should note that macOS Mojave seems to do a really good job of keeping the clock accurate by itself and when I ran this new command, my clock was accurate to within 0.1 seconds.

The first thing to do is to test the command to make sure it works properly.  I’ve done this on two systems now and each time I had run an additional two commands just to get it running.

On your Mac, open a terminal window and type the following:

sntp -sS pool.ntp.org

You’ll almost certainly be prompted for your password – This is the main administrator account password for your Mac computer, enter it and press return.

There’s a very good chance you’ll get the following error message

If you do, you need to type the two following commands

sudo touch /var/db/ntp-kod
sudo chmod 666 /var/db/ntp-kod

Once you’ve entered those two commands, try again. If all is well, you’ll see something like this:

Now you need to schedule this so that it runs automatically.  The following instructions are pretty much identical to those posted in my original blog entry.

macOS has a built in task scheduler called cron and it’s relatively straightforward to add an entry to cron.

By default, macOS uses a very powerful text editor to edit system files but that can be a little daunting at first.  If you’re happy to use that then that’s fine, go ahead but I’m going to give you some instructions now on how to change your default system editor to nano.

In your terminal window, type the following:
nano .bash_profile

You will get an empty window just like this:

Copy (cmd-c) the following three lines of text and paste (cmd-v) them into the window:

# Set Default Editor (change ‘Nano’ to the editor of your choice)
# ————————————————————
export EDITOR=/usr/bin/nano

The window will look like this:

Press control-x, press y and then press enter to save the file.

Now either restart your Mac or simply log out and then back in.  If you don’t do this then it won’t use the editor we’ve just configured.

When you’ve logged back in, open a terminal window again and type:
sudo crontab -e

Enter your password as before.

Unless you’ve already added something into cron previously, this file will be empty.  You may have followed my instructions on cleaning a useless cache and if so, there will be a line there already.

It doesn’t matter whether the file is empty or not.
Using your cursor keys. scroll to the bottom and add a new line:
*/60 * * * * sntp -sS pool.ntp.org

This line is adding a task to automatically run the command we discussed above every sixty minutes. You could change the 60 to be any number you want and it will run at those intervals.  For more information about how to configure cron, please see here.

Press control-x, press y and then press enter to save the file. If you get the following prompt, click the OK button.

You’re done.  Your Mac will now keep very accurate time with no further intervention.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.