0

I would like to start an ntpd on my MacOSX 10.8. ntpd is configured correctly and runs when started manually. I would like to start it on boot time with lauchdaemon.

I created this com.stefan.ntp.plist file in /Library/LaunchDaemons:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.stefan.ntpd</string>
        <key>Program</key>
        <string>/usr/sbin/ntpd</string>
        <key>ProgramArguments</key>
        <array>
            <string></string>
        </array>
    </dict>
</plist>

Added it to the Launchdaemon with

launchctl load /Library/LaunchDaemons/com.stefan.ntpd.plist

However, it does not start.

sh-3.2# launchctl list | grep ntpd
-   0   com.stefan.ntpd
sh-3.2# launchctl start com.stefan.ntpd
sh-3.2# launchctl list | grep ntpd
-   0   com.stefan.ntpd

Any ideas?

1
  • Maybe try to use launchd to run a simple shell script which appends a timestamp to /tmp/hello.txt first and then try to include ntpd in a second step.
    – nohillside
    Aug 5, 2013 at 13:11

2 Answers 2

1

There should be an ntpd process started by /System/Library/LaunchDaemons/org.ntp.ntpd.plist by default in 10.8.

The plist is also missing <key>RunAtLoad</key><true/>, but I couldn't get this to work either:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.stefan.ntpd</string>
  <key>Program</key>
  <string>/usr/sbin/ntpd</string>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>
1
  • 1
    It works wit <key>Program</key> <string>/usr/libexec/ntpd-wrapper</string> <key>RunAtLoad</key>
    – Stef
    Aug 5, 2013 at 13:29
0

You are missing the -w flag in the launchctl command. The -w flag will ensure that the daemon specified will start up automatically upon reboot.

See Launchctl difference between load and start, unload and stop

In your case, the command should be:

sudo launchctl load -w /Library/LaunchDaemons/com.stefan.ntpd.plist

And I would just slightly modify the ntpd.plist provided by Apple as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.stefan.ntpd</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/libexec/ntpd-wrapper</string>
    </array>
    <key>KeepAlive</key>
    <dict>
      <key>PathState</key>
      <dict>
    <key>/private/etc/ntp.conf</key>
    <true/>
      </dict>
    </dict>
    <key>EnableTransactions</key>
    <true/>
    <key>SHAuthorizationRight</key>
    <string>system.preferences</string>
  </dict>
</plist>

P.S. If you want, you can also add to the plist the following key:

<key>RunAtLoad</key>

But I prefer using the the -w flag with launchctl instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .