Mac OS X,  Mac OS X Server

Creating a LaunchAgent

If you want to make a program start at a certain time or always run on Mac OS X then you should use launchd. Launchd can start your web, FTP or SMB daemon’s or even an application or open a file. Launchd uses property lists to identify various parameters for the agents you will be creating. Using Property List editor, create a new list and add the following items:

  • Root dictionary
  • Label string
  • ProgramArguments array
  • OnDemand boolean

Set if we are going to use TextEdit as an example, then set them like so:

  • Label: com.apple.TextEdit
  • OnDemand: false
  • ProgramArguments: one child, a string: /Applications/TextEdit.app/Contents/MacOS/TextEdit

Save this file in ~/Library/LaunchAgents/com.apple.TextEdit.plist or /Library/LaunchAgents/com.apple.TetEdit.plist and you have now created your first LaunchAgent.