Scheduling system tasks on OSX can be achieved with either with cron or launchd. At a first glance, it looks like launchd supersedes cron on OSX and when a job is created in cron, launchd actually does all the work.
Anyways, I decided to have a crack at creating a scheduled task through launchd which updates brew for me.
Creating a scheduled task is fairly straightforward. This consists of creating a launch agent, which is a structured plist file that looks a lot like XML. All user launch agents are stored in
~/Library/LaunchAgents and run in context of the currently logged in user. These agents are all automatically loaded on boot. For more info on launchd, check out this guide.
The plist I created is named
local.brewupdate.job.plist, it basically runs brew with the update argument everyday at 2pm. After the job runs, two files are created in
/tmp/local.brewupdate.job.stdout writes out what is displayed to console when brew update is run. This is typically a list of updated programs, taps, etc. If a launch error occurs, specific debug messages are written to