Outils pour utilisateurs

Outils du site


lancer_un_programme_au_demarrage

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
lancer_un_programme_au_demarrage [2016/09/03 14:42] simonlancer_un_programme_au_demarrage [Date inconnue] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1
Ligne 1: Ligne 1:
-====== Lancer un programme au démarrage ====== 
-On peut souvent avoir besoin d'un programme, d'un service ou d'un script qui se lance au démarrage. Dans les dernières versions de Raspbian, c'est le système d'initialisation [[systemd]] qui est utilisé. La procédure pour démarrer un programme au démarrage n'est plus la même qu'avec les anciens systèmes d'initialisation. 
  
-D'abord, je copie le script du service ssh pour partir d'une base fonctionnelle : 
-<code bash> 
-$ sudo cp /etc/systemd/system/multi-user.target.wants/ssh.service /etc/systemd/system/multi-user.target.wants/MY-SERVICE.service 
-</code> 
- 
-Ensuite, on modifie le fichier ''MY-SERVICE.service'' : 
-<code bash> 
-$ sudo nano /lib/systemd/system/MY-SERVICE.service 
-$ sudo cat /lib/systemd/system/MY-SERVICE.service 
-[Unit] 
-Description=Script pour lancer MY-SERVICE 
- 
-[Service] 
-ExecStart=/home/pi/my-service.sh 
- 
-[Install] 
-WantedBy=multi-user.target 
-</code> 
- 
-Ensuite, on active le service avec la commande suivante: 
-<code bash> 
-$ sudo systemctl enable MY-SERVICE.service 
-Created symlink from /etc/systemd/system/multi-user.target.wants/MY-SERVICE.service to /lib/systemd/system/MY-SERVICE.service. 
-</code> 
- 
-On vérifie : 
-<code bash> 
-$ sudo systemctl status MY-SERVICE.service 
-(...) 
-</code> 
- 
-On relance le daemon avec systemctl, on relance le service ''MY-SERVICE'' et on vérifie son statut: 
-<code bash> 
-$ sudo systemctl daemon-reload 
-$ sudo systemctl restart MY-SERVICE.service 
-$ sudo systemctl status MY-SERVICE.service 
-(...) 
-</code> 
- 
- 
-===== Sources ===== 
-  * [[https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples|how to configure a linux service to start automatically after a crach or reboot (digitalocean.com)]] 
-  * [[http://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/|how to autorun a python script on boot using systemd (raspberrypi-spy.co.uk)]] 
-  * [[https://mespotesgeek.fr/fr/execution-dun-script-interactif-au-boot-avec-systemd/|execution d'un script interactif au boot avec systemd (mespotesgeek.fr)]] 
-  * [[https://learn.adafruit.com/running-programs-automatically-on-your-tiny-computer/systemd-writing-and-enabling-a-service|running programs automatically on your tiny computer (adafruit.com)]] 
lancer_un_programme_au_demarrage.1472913729.txt.gz · Dernière modification : 2020/08/09 12:59 (modification externe)