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").
Asked
Active
Viewed 1,264 times
1 Answers
1
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 $?

AD7six
- 2,920
- 2
- 21
- 23

Fabio Abreu
- 21
- 5
-
`echo $'Execute start!'` - Is that a typo..? There's no reason to turn strings into variables. – AD7six Apr 12 '15 at 12:54
-
2@AD7six That's not what the `$` means. Quoting the man page: `A double-quoted string preceded by a dollar sign ($"string") will cause the string to be translated according to the current locale.` – kasperd Apr 12 '15 at 14:36