I have a script monta.sh to mount an external volume:

#!bin/sh
mkdir -p /Volumes/remvol
mount_smbfs //user:password@server/folder /Volumes/remvol

Then I have a com.jo.monta.plist to launch the script after system boot placed in /Library/LaunchDaemons:

<?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.jo.monta</string>
    <key>Disabled</key>
    <false/>
    <key>UserName</key>
    <string>admin</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/admin/scripts/monta.sh</string>
    </array>
    <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <false/>
    </dict>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

I've tested the script from the command line and it works, however if I log in after boot the volume is not mounted.

It seems like the plist file doesn't load? what's wrong?

  • Small correction to the script: #!bin/sh should be #!/bin/sh – Graham Miln Feb 29 '16 at 8:14
  • Do you see any output in system.log regarding this launchd job? You can see the contents of system.log using Applications > Utilities > Console.app. – Graham Miln Feb 29 '16 at 8:16
  • @GrahamMiln Thanks, I corrected my script. I haven't seen any reference to com.jo.monta in the system log, I have also used launchctl list | grep monta to see if there was something and no reference neither. – naio Feb 29 '16 at 8:45
  • Why are you using ProgramArguments instead of Program (which is a simple key/value pair, not an array, see man launchd.plist for details)? – nohillside Feb 29 '16 at 9:31
up vote 3 down vote accepted

The script and the plist work perfectly well if you make following changes:

add a slash in /Users/admin/scripts/monta.sh:

#!/bin/sh
mkdir -p /Volumes/remvol
mount_smbfs //user:password@server/folder /Volumes/remvol

proper ownership of com.jo.monta.plist:

sudo chown root:wheel /Library/LaunchDaemons/com.jo.monta.plist

proper file mode bits of /Users/admin/scripts/monta.sh:

chmod 755 /Users/admin/scripts/monta.sh

load the launch daemon:

sudo launchctl load /Library/LaunchDaemons/com.jo.monta.plist
  • @naio Try chmod 755 /Users/admin/scripts/monta.sh – klanomath Feb 29 '16 at 14:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.