You need to make friends with launchd . You need to create launchd configuration files that are located in one of five locations:
~/Library/LaunchAgents : user agents provided by the user.
/Library/LaunchAgents : agents for each user provided by the administrator.
/Library/LaunchDaemons : System-wide daemons provided by the administrator.
/System/Library/LaunchAgents : Agents for each user provided by Mac OS X.
/System/Library/LaunchDaemons : System-wide daemons provided by Mac OS X.
A daemon is a system-wide service for which there is one instance for all clients. Agent - This is a service that runs for each user.
The configuration files are in the form of a list of properties .
The syntax is simple but easy to make mistakes. The Wikipedia article provides a good summary of options if the man page is not to your liking.
Essentially, what you do is install somewhere the actual command line tool (your service), and then create the launchd configuration plan and put it in one of the above locations. You can configure plist so that launchd starts your service at startup, either periodically or in response to various actions (for example, the contents of a folder).
There is a good in-depth article here.
source share