You need to look at launchd
which uses *.plist setup files in:
/Library/LaunchAgents/
, /Library/LaunchDaemons/
and ~/Library/LaunchAgents/
Under /System/Library/LaunchAgents/
and /System/Library/LaunchDaemons/
are the ones provided by Mac OS X.
When you e.g. install postgresql form Macports, there will also be installed an org.macports.postgresql93-server.plist
file under /Library/LaunchDaemons/
(it is a link to a .plist file which is installed under /opt/local/etc/LaunchDaemons/org.macports.postgresql93-server
), but the daemon isn't enabled at install.
The content of this .plist file is (the key <key>Disabled</key><true/>
need to be set to false, if you need to enable the daemon):
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>org.macports.postgresql93-server</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/daemondo</string>
<string>--label=postgresql93-server</string>
<string>--start-cmd</string>
<string>/opt/local/etc/LaunchDaemons/org.macports.postgresql93-server/postgresql93-server.wrapper</string>
<string>start</string>
<string>;</string>
<string>--stop-cmd</string>
<string>/opt/local/etc/LaunchDaemons/org.macports.postgresql93-server/postgresql93-server.wrapper</string>
<string>stop</string>
<string>;</string>
<string>--restart-cmd</string>
<string>/opt/local/etc/LaunchDaemons/org.macports.postgresql93-server/postgresql93-server.wrapper</string>
<string>restart</string>
<string>;</string>
<string>--pid=none</string>
</array>
<key>Debug</key><false/>
<key>Disabled</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>
start-stop-daemon
. – Sridhar Sarnobat Nov 30 '17 at 01:26