[launchd-dev] fork & exit in Shell Script (Revisited)
Charles Darwin
DarwinsKernel at gmail.com
Mon Nov 3 12:43:10 PST 2008
On 29-Oct-08, at 2:59 PM, Charles Darwin wrote:
>
> On 29-Oct-08, at 2:22 PM, Damien Sorresso wrote:
>
>> On Oct 29, 2008, at 10:36 AM, Charles Darwin wrote:
>>> Hi all,
>>>
>>> I have a shell script that runs RunAtLoad. Here is the script:
>>>
>>> ########
>>> /bin/test -f /Volumes/tutorials || /bin/mkdir -p /Volumes/
>>> tutorials && /sbin/mount_afp afp://username:password@url/
>>> tutorials/ /Volumes/tutorials/
>>>
>>>
>>> /bin/test -f /Volumes/homes || /bin/mkdir -p /Volumes/homes && /
>>> sbin/mount_afp afp://username:password@url/homes/ /Volumes/homes/
>>> ########
>>> and here is the 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>label</string>
>>> <key>ProgramArguments</key>
>>> <array>
>>> <string>path/to/script</string>
>>> </array>
>>> <key>StartCalendarInterval</key>
>>> <dict>
>>> <key>RunAtLoad</key>
>>> <true/>
>>> </dict>
>>> </dict>
>>> </plist>
>>
>> Firstly, it is convention to use the reverse-DNS scheme for your
>> job label (i.e. com.domain.something). Secondly, RunAtLoad belongs
>> under the root node of the plist, not under StartCalendarInterval.
>> Try restructuring your plist like this...
>>
>>> <?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>label</string>
>>> <key>ProgramArguments</key>
>>> <array>
>>> <string>path/to/script</string>
>>> </array>
>>> <key>RunAtLoad</key>
>>> <true/>
>>> </dict>
>>
>> --
>> Damien Sorresso
>> BSD Engineering
>> Apple Inc.
>>
>
> Solved. Thanks Damien.
>
> Charles
>
>
Here we go again; same script, same daemon: what happens is that when
user turn on the machine and then logs in our daemon runs the script
with no problem. Now if user logs out and then logs back in daemon
sits there and does nothing.
$ launchctl list
<label>
$ launchctl load /path/to/<label>.plist #and we are in business again
(except that `Workaround Bonjour: Unknown error: 0` error message)
What's missing?
Thanks,
Charles
P.S: I think I need to shut it down but how? Would TimeOut key work?
What's the proper way of doing this?
Charles
P.S.0: Adding `launchctl unload /Users/pm/Library/LaunchDaemons/
<label>.plis` to the end of the script doesn't help either (I hope
someone's reading this).
Charles
More information about the launchd-dev
mailing list