How do I create a daemon for *nix machines that starts up when the OS boots up? On MacOS, I am guessing the best option would be a brew service. What are the best options for linux?
closed as too broad by Michael Homer, Romeo Ninov, Anthon, Jeff Schaller♦, Rui F Ribeiro Jul 13 '17 at 12:04
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
It depends on the distro, but many distros nowadays are moving towards
systemd as the init service. For that case, you'd create a systemd service: see the systemd.directives(7) manpage, the systemd homepage and google for "systemd service example". Here's one example (see example 9.18 in this section) which starts emacs as a daemon :
[Unit] Description=Emacs: the extensible, self-documenting text editor [Service] Type=forking ExecStart=/usr/bin/emacs --daemon ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)" Environment=SSH_AUTH_SOCK=%t/keyring/ssh Restart=always [Install] WantedBy=default.target