Pour la station météo, certains programmes doivent fonctionner en tache de fond. Pour cela on utilise des démons.
Dans mon exemple j’ai un script Python à lancer. Ce script est capable de fonctionner en mode autonome mais je souhaite l’intégrer au système. Mon service s’appelle « launcher ».
#!/bin/sh
### BEGIN INIT INFO
# Provides:          launcher
# Required-Start:    $remote_fs
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run weathergh
# Description:       Run weatherg-hardware as daemon.
### END INIT INFO
. /lib/lsb/init-functions
[ -f /etc/default/rcS ] && . /etc/default/rcS
PATH=/bin:/usr/bin:/sbin:/usr/sbin
SCRIPT_DIR=/home/rep/
SCRIPT=script_a_lancer.py
case "$1" in
  start)
    log_begin_msg "Running launcher"
    cd $SCRIPT_DIR
    python $SCRIPT --daemon
    log_end_msg 0
    ;;
  stop)
    log_begin_msg "Stopping launcher"
    cd $SCRIPT_DIR
    python $SCRIPT --quit
    log_end_msg 0
    ;;
  force-reload|restart)
    $0 stop
    $0 start
    ;;
  status)
    exit 0
    ;;
  *)
    log_success_msg "Usage: /etc/init.d/launcher {start|stop|restart|force-reload|status}"
    exit 1
esac
exit 0
Copier le script launcher dans le répertoire /etc/init.d/ et donner les droits d’exécution chmod +x /etc/init.d/launcher
Enregistrer le service et le démarrer :
update-rc.d launcher defaults services start launcher
Sources :
https://openclassrooms.com/courses/faire-un-demon-sous-linux


