NoobWithRaspberry
Posts: 8
Joined: Tue Apr 05, 2016 1:07 pm

Lancer un Script bash au démarrage du Pi

Tue May 17, 2016 2:13 pm

Bonjour,

Ce sujet a dû être traité beaucoup de fois. Cependant, les résultats sur internet me refroidissent un peu.
Il y a plusieurs façon différentes de lancer un script au démarrage, mais je veux être sûr de faire aucune erreur.
Voilà, j'ai un petit programme bash qui surveille un fichier de log en continu. J'aimerai que ce script soit lancé à chaque fois que j'allume mon RaspberryPi 3.

Des idées ? Je vous remercie d'avance.

PS : Je suis débutant sur Linux :(

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Lancer un Script bash au démarrage du Pi

Tue May 17, 2016 2:34 pm

NoobWithRaspberry wrote:Ce sujet a dû être traité beaucoup de fois. Cependant, les résultats sur internet me refroidissent un peu.
Repetition is good...
NoobWithRaspberry wrote:PS : Je suis débutant sur Linux :(
Welcome to gnu+linux! :D
NoobWithRaspberry wrote: Il y a plusieurs façon différentes de lancer un script au démarrage, mais je veux être sûr de faire aucune erreur.
If you're new to linux, best to start with the simple reliable way, rc.local (systemd is for later...)
NoobWithRaspberry wrote: Voilà, j'ai un petit programme bash qui surveille un fichier de log en continu. J'aimerai que ce script soit lancé à chaque fois que j'allume mon RaspberryPi 3.
Des idées ? Je vous remercie d'avance.
1) make a bin directory in /home/pi

Code: Select all

cd /home/pi
mkdir bin
2) put your script name.sh in your new bin directory and make it executable

Code: Select all

mv name.sh ~/bin/
chmod 0754 ~/bin/name.sh
3) edit /etc/rc.local with nano

Code: Select all

sudo nano /etc/rc.local 
Place the following lines above the 'exit 0' DO NOT remove the exit 0

Code: Select all

# autostart my script name.sh
su - pi -c "/home/pi/bin/name.sh &"
Reboot your PI

Voila!
marcus
:ugeek:

NoobWithRaspberry
Posts: 8
Joined: Tue Apr 05, 2016 1:07 pm

Re: Lancer un Script bash au démarrage du Pi

Tue May 17, 2016 3:19 pm

Je te remercie c'est parfait pour moi ! :D

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Lancer un Script bash au démarrage du Pi

Tue May 17, 2016 3:21 pm

NoobWithRaspberry wrote:Je te remercie c'est parfait pour moi ! :D
Vous êtes les bienvenus
marcus
:ugeek:

Return to “Français”