I am trying to use some init.d script under OS X and I while some are just working properly, I discovered quite a few that to rely on /sbin/start-stop-daemon and I am looking for a port of it for OS X.

Any ideas?

Note, I know that OS X does not have support for init.d but there is nothing stoping you from using it to start/stop some services. It is much easier to install things like postgres, nginx using brew and control them using the usual service name start|stop|restart.

  • I too want this. I don't want to use a separate tool because I want to play with it locally on my Macbook for learning before I make changes to a Linux server running my apps which uses start-stop-daemon. – Sridhar-Sarnobat Nov 30 '17 at 1:26

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'>
  • Man that's a lot of work. Plain old Unix design is so much more compact. And it's not just Mac OS X that are burdening the user here, systemd and upstart have gone in this direction too. – Sridhar-Sarnobat Dec 12 '17 at 1:28

Rene Larsen's answer holds the secret but it was not called out. What you want to do is to install MacPorts, which provides the daemondo program (installed to /opt/local/bin/daemondo on my system).

From the help screen: "daemondo is a wrapper program that runs daemons." It appears to provide arguments and functionality similar to start-stop-daemon.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .