# LaunchAgents
> An assorted collection of useful LaunchAgent examples. Part of [Awesome OS X Command Line](https://github.com/herrbischoff/awesome-osx-command-line).
## Table of Contents
- [Basic Examples](#basic-examples)
- [Homebrew](#homebrew)
## Basic Examples
### Periodical Job Template
Run job every 5 minutes.
```xml
Label
com.example.touchsomefile
ProgramArguments
touch
/tmp/helloworld
StartInterval
300
```
### Periodical via Calendar Interval Job Template
```xml
Label
com.example.touchsomefile
ProgramArguments
touch
/tmp/helloworld
StartCalendarInterval
Minute
45
Hour
13
Day
7
```
### Monitoring Folder Job Template
```xml
Label
com.example.watchhostconfig
ProgramArguments
syslog
-s
-l
notice
somebody touched /etc/hostconfig
WatchPaths
/etc/hostconfig
```
## Homebrew
### Periodic Homebrew Update and Upgrade
To leverage the notification system, this agent requires [terminal-notifier](https://github.com/julienXX/terminal-notifier), which can be installed via `brew install terminal-notifier`.
```xml
Label
com.example.homebrew-upgrade
ProcessType
Background
ProgramArguments
/bin/sh
-c
/usr/local/bin/brew update && /usr/local/bin/brew upgrade && /usr/local/bin/terminal-notifier -title 'Homebrew Upgrader' -message 'Homebrew upgraded!' -appIcon http://cdn.curvve.com/wp-content/uploads/2013/09/homebrew_osx_logo.png
RunAtLoad
StandardErrorPath
/tmp/com.example.homebrew-upgrade.stderr
StandardOutPath
/tmp/com.example.homebrew-upgrade.stdout
StartCalendarInterval
Hour
8
```
## License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.