launchd question
Axel Luttgens
luttgens at fusl.ac.be
Sat Mar 3 03:41:13 PST 2007
On 1/03/07 21:41, Christopher Hunt wrote:
> On 02/03/2007, at 7:00 AM, macosx-admin-request at omnigroup.com wrote:
>
>> [...]
>> I don't think it is at all that simple.
>> Every LaunchAgent I've
>> PROPERLY setup has worked just fine.
>
> As Apple said, as long as you don't log out then all should be well.
> Do you log out?
>
>> However, osascript ASSUMES the
>> Finder is present, so without a finder it's going to be weird.
>
> So how come then that cron works just fine for me? I have a crontab
> for the specific user - same user, same environment, same command.
> The osascript doesn't work under launchd but it does under cron.
>
>>
>> I suspect there's more to this than simply "they don't work".
>
> I'm curious as to whether you're logging out or not. If you're not
> logging out then things might be fine for you.
I would agree with you, Christopher: whether the Finder is present or
not shouldn't have any impact in this case.
On the other hand, according to your various emails, it seems you are
encountering problems even within a Finder environment (but I may be
wrong: I sometimes felt lost).
So, it would be nice to compare what's happening on your box against
another one.
(let's first start with very basic facts...)
Could you try the following, and tell us whether you observe dissimilar
behaviors?
1. Create a regular user "test", without admin rights.
2. Put this one into ~test/Library/LaunchAgents:
<?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>Debug</key>
<true/>
<key>Label</key>
<string>com.classactionpl.restartvision</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>-e</string>
<string>tell application "TextEdit" to quit</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
3. Do various log in/out as described in following comented excerpt of
system.log:
3.1. Log in as user "test":
Mar 3 11:11:06 ALMbp
/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow:
Login Window Application Started
Mar 3 11:11:06 ALMbp loginwindow[1242]: Login Window Started
Security Agent
Wait 5-6 minutes; as the target of the Quit event, TextEdit is
quickly launched then quit every minute. On the other hand, if
TextEdit is already running because user "test" has launched it,
it is just quit.
Everything thus "works" as expected.
3.2. Now, log out, then log in as user "test" again:
Mar 3 11:17:23 ALMbp
/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow:
Login Window Application Started
Mar 3 11:17:23 ALMbp loginwindow[1287]: Login Window Started
Security Agent
Mar 3 11:18:15 ALMbp launchd[1255]:
com.classactionpl.restartvision: exited abnormally: Abort trap
Mar 3 11:18:15 ALMbp launchd[1255]:
com.classactionpl.restartvision: 9 more failures without living at least
60 seconds will cause job removal
[...]
Mar 3 11:26:15 ALMbp launchd[1255]:
com.classactionpl.restartvision: exited abnormally: Abort trap
Mar 3 11:26:15 ALMbp launchd[1255]:
com.classactionpl.restartvision: 1 more failure without living at least
60 seconds will cause job removal
Mar 3 11:27:15 ALMbp launchd[1255]:
com.classactionpl.restartvision: exited abnormally: Abort trap
Mar 3 11:27:15 ALMbp launchd[1255]:
com.classactionpl.restartvision: too many failures in succession
As expected, we have encountered that well-know problem with launch
agents: they don't quit with the user's session, so that they have
lost their context on subsequent logins.
Here, having waited long enough to allow for 10 failures, the job
thus gets unloaded.
3.3. So, log out, then log in as user "test" again:
Mar 3 11:28:12 ALMbp
/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow:
Login Window Application Started
Mar 3 11:28:12 ALMbp loginwindow[1333]: Login Window Started
Security Agent
As expected, the job is re-loaded and everything works fine with
TextEdit again.
3.4. Log out, then log in as another user on the box:
Mar 3 11:29:37 ALMbp
/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow:
Login Window Application Started
Mar 3 11:29:37 ALMbp loginwindow[1363]: Login Window Started
Security Agent
Mar 3 11:30:20 ALMbp osascript: kCGErrorRangeCheck : Window Server
communications from outside of session allowed for root and console user
only
Mar 3 11:30:20 ALMbp launchd[1346]:
com.classactionpl.restartvision: exited abnormally: Abort trap
Mar 3 11:30:20 ALMbp launchd[1346]:
com.classactionpl.restartvision: 9 more failures without living at least
60 seconds will cause job removal
[...]
Exactly what was to be expected, thus...
Axel
More information about the MacOSX-admin
mailing list