OT LaunchDaemon

Craig Treleaven ctreleaven at macports.org
Sun Oct 2 15:30:41 CEST 2016


> On Oct 1, 2016, at 11:43 PM, James Linder <jam at tigger.ws> wrote:
> 
> Over the years I’ve seen many clever people here, perchance one of them will cast an eye and say THERE . . .
> 
> I’m trying to run a rc.local at start up
> I created a launchdaemon
> 
> haycorn:jam root# cat /Library/LaunchDaemons/local.startup.plist
> <?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>local.startup</string>
>    <key>Disabled</key>          <false/>
>    <key>RunAtLoad</key>         <true/>
>    <key>KeepAlive</key>         <false/>
>    <key>LaunchOnlyOnce</key>    <true/>
>    <key>ProgramArguments</key>
>      <array>
>       	<string>/bin/bash</string>
>       	<string>-c</string>
>        <string>/etc/rc.local</string>
>      </array>
> </dict>
> </plist>
> 
> It does not run. Following the launchd.info->troubleshooting www everything does run without complaint. 
> (Im creating a ramdisk, but what ever is in rc.local)
> haycorn:jam root# ls -l /etc/rc.local
> -rwxr-xr-x  1 root  wheel  108  2 Oct 09:58 /etc/rc.local
> haycorn:jam root# cat /etc/rc.local
> #!/bin/bash
> 
> DISK_ID=$(hdiutil attach -nomount ram://204800)
> diskutil erasevolume HFS+ "ramdisk" ${DISK_ID}
> 
> I’ve tried specifing <key>Program</key> and 644 permissions on rc.local

[Try again using the righ email.]

I’m no expect, but I don’t think you need the “-c” parameter.  You already have a reference to a file.

You may also want to add keys to direct stdout and stderr to a file.  Ala:

<key>StandardOutPath</key>
<string>/tmp/test.stdout</string>
<key>StandardErrorPath</key>
<string>/tmp/test.stderr</string>

I think the following web site is pretty good at explaining how to use launchd plists:

http://launchd.info

You can also check ‘man launchd.plist’ for a reference.

Craig


More information about the macports-users mailing list