Running shell script on system startup

Could anyone help me with this at all? I’m trying to run the commands below when the system starts up, as root. I’ve tried all sorts (including Lingon) but just can’t get it to work. Any advice is appreciated.

sudo syslog -c servermgrd In
sudo syslog -c mDNSResponder Cr

Hello.

I don’t know if launchd has taken over everything, or if the rc.common file is still executed. So I can only advise you to read the SystemStartupTopics devdoc for your version of OS X, and inject the commands into some common startup file, but no sooner than it will work, (like after the filesystem is mounted and the system is up and running.)

For clarity: I mean that you should find some shell script that is executed by the system during boot, and insert your commands there, but it must be at the very end of it, so that asl and mdnsResponder are in fact able to run.

A launchDaemon is the answer:

Runs as root:

https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.pdf

Create a plist, with root:wheel ownership and throw it into /Library/LaunchDaemons

It will point to a script that contains whatever you wish. Give this 755 permissions

Ensure that you have RunAtLoad also

Everything is in the PDF

I think you’ll need the StartupItems folder in your /Library folder. here some documentation