Scheduling tasks on Mac

From munkjensen.net/wiki

Why would i do that?

Well… you are here because you need to do it - so ;-)


Online plist creator

launched - A launchd.plist generator

Using Terminal

Execute

gem install lunchy && lunchy --help

Fetching: lunchy-0.9.0.gem (100%)

Successfully installed lunchy-0.9.0
Parsing documentation for lunchy-0.9.0
Installing ri documentation for lunchy-0.9.0
Done installing documentation for lunchy after 0 seconds

1 gem installed

Lunchy 0.9.0, the friendly launchctl wrapper
Usage: lunchy [start|stop|restart|ls|list|status|install|uninstall|rm|show|edit] [options]

   -x, --exact                      Force exact (case insensitive) match when specifying a [pattern]
   -F, --force                      Force start (disabled) agents
   -v, --verbose                    Show command executions
   -w, --write                      Persist command
   -l, --long                       Display absolute paths when listing agents
   -s, --symlink                    Use a symlink for installation

Supported commands:

ls [-l] [pattern]       Show the list of installed agents, with optional [pattern] filter
list [-l] [pattern]     Alias for 'ls'
start [-wF] [pattern]   Start the first agent matching [pattern]
stop [-w] [pattern]     Stop the first agent matching [pattern]
restart [pattern]       Stop and start the first agent matching [pattern]
status [pattern]        Show the PID and label for all agents, with optional [pattern] filter
install [-s] [file]     Install [file] to ~/Library/LaunchAgents or /Library/LaunchAgents (whichever it finds first)
uninstall [name]        Uninstall [name] from ~/Library/LaunchAgents or /Library/LaunchAgents (whichever it finds first)
show [pattern]          Show the contents of the launchctl daemon file
edit [pattern]          Open the launchctl daemon file in the default editor (EDITOR environment variable)

-w will persist the start/stop command so the agent will load on startup or never load, respectively. -l will display absolute paths of the launchctl daemon files when showing list of installed agents. -x will force exact matching of the [pattern] for any command that uses a pattern

Example:

lunchy ls
lunchy ls -l nginx
lunchy start -w redis
lunchy stop mongo
lunchy status mysql
lunchy install /usr/local/Cellar/redis/2.2.2/io.redis.redis-server.plist
lunchy show redis
lunchy edit mongo
lunchy uninstall -x elasticsearch # will not try to uninstall elasticsearch14

Note: if you run lunchy as root, you can manage daemons in /Library/LaunchDaemons also.