1

so i'm having a few troubles with launchd

I made this plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>mosek.mountd</string>
    <key>ProgramArguments</key>
    <array>
        <string>/etc/mountd</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

My problem is this. When i load the script manually:

launchctl load /Library/LaunchDaemons/script.plist

It works like a charm. It load perfectly, and runs the script as it should. now when I reboot, it loads the script as it should, but now the script won't start. Though when I start the script

launchctl start mosek.mountd

it works. So it must be ignoring the "RunAtLoad" key, when it loads the script on reboot. Why does it do that, and how do I fix it?

cheers in advance

edit:
    I forgot to mention that I also made root the owner of the file by running:
         chmod root /Library/LaunchDaemons/script.plist
    and it still wouldn't work

2 Answers 2

1

Check your permissions. The file script.plist should look like this

-rw-r--r-- 1 wheel 410 16 ...

From man launchctl

Note that per-user configuration files (LaunchAgents) must be owned by the user loading them. All system-wide daemons (LaunchDaemons) must be owned by root. Configuration files must not be group- or world-writable.

6
  • Hi. sorry i forgot to mention that. i ran chmod root /Library/LaunchDaemons/script.plist, so I don't think that is the problem
    – Tomas
    Commented Oct 24, 2013 at 9:17
  • the file permission looks like this: -rw-r--r-- 1 root wheel 404
    – Tomas
    Commented Oct 24, 2013 at 9:19
  • please try these steps to debug your plist: 1. set the launcdctr log level to debug sudo launchctl log level debug (debug, info, notice, warning, error, critical, alert, emergency) 2. Tail the system.log tail -f /var/log/system.log 3. set the launcdctr log level back to error sudo launchctl log level error from obscured clarity
    – napcae
    Commented Oct 24, 2013 at 9:30
  • I tried what you suggested. I unloaded the plist, set the loglevel to debug, loaded the plist, tail the system log. when I tailed the system log, there wasn't anything on my plist. does this mean it didn't run, cause it did, or does it mean, that there aren't any bugs in it?
    – Tomas
    Commented Oct 24, 2013 at 10:15
  • I added a KeepAlive key, and that did the trick. But as far as I understand the KeepAlive key, it runs the process over and over again indefinitely. I wanted it to run a single time when the system rebooted, and not more then that
    – Tomas
    Commented Oct 24, 2013 at 10:30
0

My friend, I suggest a few modifications to the plist file:

Add:

<key>Program</key>
     <string>/where/the/script/you/want/to/be/executed/resides</string>

Then modify the ProgramArguments to reflect the 'basename' of the script -- its name without the full path, or 'dirname'. I mean like this, assuming '/usr/local/bin/mosek.mountd.sh' to be the script you want run:

<key>Program</key>
     <string>/usr/local/bin/mosek.mountd.sh</string>
<key>ProgramArguments</key>
     <array>
          <string>mosek.mountd.sh</string>
          <string>/etc/mountd</string>
     </array>

This should resolve the problem. Please let me know if this helps.

F.

You must log in to answer this question.

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