MacOS – launchd seems ignore StartCalendarInterval on Yosemite


I tried to update Homebrew on time with launchd. My plist file is presented here:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

It does work somehow: I can execute launchctl start ms.liu.homebrew.update manually to update my Homebrew. However, launchd doesn't execute this service periodically: last changes to the file which stdout redirects to is two days ago.

I tried to get info about this service but got nothing:

> launchctl print user/%MyPID%/ms.liu.homebrew.update`` 
Could not find service "ms.liu.homebrew.update" in domain for uid: %MyPID%

It looks like I haven't successfully loaded my service. How? I used launchctl load but it seems that it has been deprecated. Man page recommends bootstrap instead:

> launchctl bootstrap user/%MyPID% %Path-to-plist%
> %Path-to-plist%: Service cannot load in requested session

What should I do? How to properly use launchctl bootstrap and launchctl print?

I am running OS X Yosemite GM Candidate 1 on MacBookPro with Retina display (2013).

Best Answer

I’m only just starting to work this stuff out, so this answer is tentative – but I hope it’s more helpful than no answer at all. (I would have left it as a comment if I had enough rep.)

Is this plist in your ~/Library/LaunchAgents directory? It seems that these are bootstrapped into your gui domain, not your user domain. So you can do:

launchctl print gui/%UID%/ms.liu.homebrew.update

and it should work. (Does it?)

Presumably the reason you can’t bootstrap it into the user domain is that it’s already bootstrapped into the gui domain.

Related Question