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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>ms.liu.homebrew.update</string> <key>UserName</key> <string>LiuMS</string> <key>ProcessType</key> <string>Background</string> <key>EnvironmentVariables</key> <key>ProgramArguments</key> <array> <string>/usr/local/bin/brew</string> <string>update</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>20</integer> <key>Minute</key> <integer>0</integer> </dict> <key>StandardOutPath</key> <string>/usr/local/logs/ms.liu.homebrew.update.out</string> <key>StandardErrorPath</key> <string>/usr/local/logs/ms.liu.homebrew.update.err</string> </dict> </plist>
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
I am running OS X Yosemite GM Candidate 1 on MacBookPro with Retina display (2013).