script python via la crontab
script python via la crontab
Je souhaite lancer via la crontab un script python
si je lance en console
sudo /usr/bin/python2.7 /home/pi/domoticz2/scripts/python/cozytouch.py
le script fonctionne par contre en sudo crontab -e:
*/1 * * * * /home/pi/domoticz2/scripts/python/cozytouch.py
ne fonctionne pas
j'ai aussi essayé
*/1 * * * * python2.7/home/pi/domoticz2/scripts/python/cozytouch.py
*/1 * * * * sudo python2.7/home/pi/domoticz2/scripts/python/cozytouch.py
*/1 * * * * /usr/bin/python2.7/home/pi/domoticz2/scripts/python/cozytouch.py
Merci de votre aide ca je seche
si je lance en console
sudo /usr/bin/python2.7 /home/pi/domoticz2/scripts/python/cozytouch.py
le script fonctionne par contre en sudo crontab -e:
*/1 * * * * /home/pi/domoticz2/scripts/python/cozytouch.py
ne fonctionne pas
j'ai aussi essayé
*/1 * * * * python2.7/home/pi/domoticz2/scripts/python/cozytouch.py
*/1 * * * * sudo python2.7/home/pi/domoticz2/scripts/python/cozytouch.py
*/1 * * * * /usr/bin/python2.7/home/pi/domoticz2/scripts/python/cozytouch.py
Merci de votre aide ca je seche
Re: script python via la crontab
bonsoir
a tu essayé ?
ou
avec toujours un espace entre python et le chemin vers ton script cozytouch.py
a tu essayé ?
Code : Tout sélectionner
*/1 * * * * python /home/pi/domoticz/scripts/python/cozytouch.pyCode : Tout sélectionner
*/1 * * * * sudo python /home/pi/domoticz/scripts/python/cozytouch.pyRe: script python via la crontab
oui ca ne fonctionne pas
Re: script python via la crontab
Bonjour
crontab -e et non pas sudo crontab -e
N'est ce pas ?
puis
*/10 * * * * sudo /home/pi/domoticz/scripts/le_nom_du_script.py /home/pi/domoticz/scripts/le_nom_du_script.py
crontab -e et non pas sudo crontab -e
N'est ce pas ?
puis
*/10 * * * * sudo /home/pi/domoticz/scripts/le_nom_du_script.py /home/pi/domoticz/scripts/le_nom_du_script.py
Raspberry pi 3, Dongle RfxCom et Zigate +, plugin de pipiche, Volets Roulants profalux, contrôle d'éclairage, détecteurs de présence, alarme incendie, pilotage livebox ...
Objectif : WAF > 1
Objectif : WAF > 1
Re: script python via la crontab
j'ai mis
*/2 * * * * sudo /home/pi/domoticz2/scripts/python/cozytouch.py /home/pi/domoticz2/scripts/python/cozytouch.py
et ca ne marche pas non plus
*/2 * * * * sudo /home/pi/domoticz2/scripts/python/cozytouch.py /home/pi/domoticz2/scripts/python/cozytouch.py
et ca ne marche pas non plus
Re: script python via la crontab
Bonjour,
De manière générale, évitez d'utiliser "sudo" dans les commandes Cron. Normalement, "sudo" est sensé vous demander un mot de passe de temps en temps (même si ce n'est pas le cas par défaut sur les distributions Pi).
Ceci étant dit, si votre script doit s'exécuter en "root", en modifiant la crontab via "sudo crontab -e", la ligne suivante devrait fonctionner pour exécuter votre script toutes les minutes :
Bon courage
De manière générale, évitez d'utiliser "sudo" dans les commandes Cron. Normalement, "sudo" est sensé vous demander un mot de passe de temps en temps (même si ce n'est pas le cas par défaut sur les distributions Pi).
Ceci étant dit, si votre script doit s'exécuter en "root", en modifiant la crontab via "sudo crontab -e", la ligne suivante devrait fonctionner pour exécuter votre script toutes les minutes :
Code : Tout sélectionner
* * * * * /usr/bin/python2.7 /home/pi/domoticz2/scripts/python/cozytouch.pyDomoticz Beta - ZStickGen5 - RFP1000 - Alexa
433 : Sondes Oregon - Prises Chacon - Sonnette Chacon - VR Somfy RTS
ZW : Modules Qubino - HRT4/ASR
433 : Sondes Oregon - Prises Chacon - Sonnette Chacon - VR Somfy RTS
ZW : Modules Qubino - HRT4/ASR
Re: script python via la crontab
ok je viens de mettre
*/2 * * * * /usr/bin/python2.7 /home/pi/domoticz2/scripts/python/cozytouch.py
ca ne fonctionne pas non plus
*/2 * * * * /usr/bin/python2.7 /home/pi/domoticz2/scripts/python/cozytouch.py
ca ne fonctionne pas non plus
Re: script python via la crontab
attention,
sudo crontab -e et crontab -e n'éditent pas le même fichier.
Chez moi, je fais:
crontab -e
puis ma ligne:
0 */6 * * * /usr/bin/python /home/pi/domoticz/scripts/python/monscript.py >/dev/null 2>&1
sudo crontab -e et crontab -e n'éditent pas le même fichier.
Chez moi, je fais:
crontab -e
puis ma ligne:
0 */6 * * * /usr/bin/python /home/pi/domoticz/scripts/python/monscript.py >/dev/null 2>&1
Raspberry Pi 3 + Raspbian Jessie Lite + Domoticz V4.9700 - RFlink USB V48 433.42MHz - Volets Somfy RTS - MySensors USB V2.1.1 - IDE Arduino 1.8.8
Re: script python via la crontab
Voici ma crontab et je n'ai que celle la
Les autres scripts sont bien lancé via cette crontab
*/2 * * * * /usr/bin/python2.7 /home/pi/domoticz2/scripts/python/cozytouch.py
*/5 * * * * /home/pi/domoticz2/scripts/nas.sh
#*50 23 * * * /home/pi/domoticz2/scripts/jf.sh
*/15 * * * * /home/pi/domoticz2/scripts/get_rain_probability.sh
*/10 * * * * /home/pi/freebox/freebox_infos.sh
quel est l'intéret de >/dev/null 2>&1 a la fin de la ligne ?
Les autres scripts sont bien lancé via cette crontab
*/2 * * * * /usr/bin/python2.7 /home/pi/domoticz2/scripts/python/cozytouch.py
*/5 * * * * /home/pi/domoticz2/scripts/nas.sh
#*50 23 * * * /home/pi/domoticz2/scripts/jf.sh
*/15 * * * * /home/pi/domoticz2/scripts/get_rain_probability.sh
*/10 * * * * /home/pi/freebox/freebox_infos.sh
quel est l'intéret de >/dev/null 2>&1 a la fin de la ligne ?
-
mike913
- Messages : 159
- Inscription : 18 oct. 2014, 10:22
- Localisation : Morsang / Orge - Essonne
- Contact :
Re: script python via la crontab
Bonjour
Moi je lance des scripts python via crontab.
Les scripts python doivent commencer par les lignes:
ensuite ils doivent être exécutables
ensuite dans le crontab j'ai les lignes:
mes scripts sont dans le répertoire /home/user/py
Moi je lance des scripts python via crontab.
Les scripts python doivent commencer par les lignes:
Code : Tout sélectionner
#!/usr/bin/env python
# coding=UTF-8
# ----------------------------------------------------------------------------ensuite dans le crontab j'ai les lignes:
Code : Tout sélectionner
@reboot /usr/local/sbin/Boot
@weekly ./py/ArchiLog.py
@daily ./py/SysLog.py
2 0 * * * ./py/purge.pyDS718+ 2 x 3To(SHR) - Firmware: DSM 7.0.1-42218
DS712+ 2 x 4To (SHR) - Firmware: DSM 6.2.4-25556
Raspberry - RFXTRX433 - Aeon Labs ZStick V2 - Domoticz
FreeBox Delta
https://meteo.folcke.net
https://wiki.folcke.net
DS712+ 2 x 4To (SHR) - Firmware: DSM 6.2.4-25556
Raspberry - RFXTRX433 - Aeon Labs ZStick V2 - Domoticz
FreeBox Delta
https://meteo.folcke.net
https://wiki.folcke.net