I'd like to create my own init script to make my program start at boot and be controlled via "service" utility in most popular Linux distributions.


  • it should be portable across different distros(it should support at least Debian/Ubuntu and RedHat/Centos)
  • it shouldn't depend on any additionally installed packages
  • it should control if my program started succesfully or encountered some kind of errors
  • it should reliably stop my program when requested (sometimes init script say "stopping... OK" but it's still running)

For example, I can do it this way:

case "$1" in
    echo "Usage: $0 {start|stop}"
    exit 1

But in this case it's required to check if program has been properly started with 'ps' and properly killed on shutdown.

Looking for the right way to do it. Is there any standard to satisfy all those systemd, upstart,etc. ?



There's no drop-in script that will work with all init systems. While you can write one that launches your daemon (similar to bin/startup.sh for tomcat), you need some config files or scripts for the actual init system in use by the target distro.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.