What is the minimal init.d script for Ubuntu?

I have a small Python-based server program that runs fine, but I want launched each time the server is rebooted. What is the least that I need to put into an /etc/init.d script to work? I only care about “stop” and “start” (and thus probably the trivial “restart”).

Answer

Im using this script for any service in linux, i wrote in bash , i think this script can help you .

http://fajlinux.com.br/scripts/script-modelo-para-qualquer-servico-linux/

#!/bin/bash
#FAJLINUX Modelo de script INIT
start() {
  echo $'Execute start!' > /var/log/my-servico.log
  Commands for start service
}

stop() {
  echo  $'Executing stop!' > /var/log/my-servico.log
  Commands for stop service
}

restart() {
  echo $'Executing restart' > /var/log/my-servico.log
  Commands for restart service
}                                                                                                                                                 

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  *)
    echo $"Use this options $0 {start|stop|restart}"
    exit 1
esac
exit $?          

Attribution
Source : Link , Question Author : Paul Hoffman , Answer Author : AD7six

Leave a Comment