Q:

OS X launchd script fails to run at startup?

I made a launchd script to run general scripts for me at startup but I can't get it to work. I'm running OS X Yosemite 10.10.5. This is my /Library/LaunchDaemons/com.craig.startup.items file (I just noticed it doesn't have a ".plist" extension. I'll add the extension and reboot after posting this question):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.craig.startup.items</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/sh</string>
        <string>/Users/cliff/startup/onlaunchd</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
</dict>
</plist>

And /Users/cliff/startup/onlaunchd contains the following:
#!/bin/sh

log=/Users/cliff/startup/status.log
echo "`date` running startup scripts." >> $log
pushd /Users/cliff/startup/scripts/
for each in `ls`; do echo "`date` Running $each" >> $log; sh $each; done
popd

There are further scripts involved but the onlaunchd doesn't ever fire because I never see the log output in /Users/cliff/startup/status.log. If I run it directly as root it works just fine. What am I missing other than potentially the extension?

A:

You should run daemon before restart:
sudo launchctl load -w /Library/LaunchDaemons/com.craig.startup.items.plist

Also pelase set +x permission chmod +x /Users/cliff/startup/onlaunchd and update plist code:
<?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.user.loginscript</string>
   <key>Program</key>
   <string>/Users/cliff/startup/onlaunchd</string>
   <key>RunAtLoad</key>
   <true/>
</dict>
</plist>

