[systemd] MyScript.service & MyScript.timer
Bonjour,
Je m'intéresse de près à systemd pour palier aux "crashs" de mon script python qui me sert à télécharger la météo sur la NOAA (méthode Grib Filter).
Il est sensible aux petites sautes d'humeurs de ce dernier :?
Ça se traduit par un fichier télécharger corrompu mais ce n'est pas le sujet ici ;)
noaadownloader.service
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
[Unit]
Description=Script NoaaDownloader.py
[Service]
User=execution
WorkingDirectory=/appli/python/NoaaDownloader/
ExecStart=./NoaaDownloader.sh || python3 NoaaDownloader.py (=> ?)
Restart=always
[Install]
WantedBy=multi-user.target |
/appli/python/NoaaDownloader/NoaaDownloader.sh contient ceci
Code:
1 2 3
|
#!/usr/bin/bash
sudo su - execution -c "cd /appli/python/NoaaDownloader ; python3 NoaaDownloader.py > /trace/python/NoaaDownloader_$(date +\%F_\%R).log 2>&1" |
Du coup je suis un peu perdu avec les $PATH car j'ai tout sectorisé ...
Les scripts se trouvent dans /appli/python/Noaadownloader/, le résultat issu du script se trouve dans /data/python/NoaaDownloader/ et /trace/python/ contient le log :weird:
noaadownloader.timer
Code:
1 2 3 4 5 6 7 8 9
|
[Unit]
Description=Run Script NoaaDownloader.sh || NoaaDownloader.py daily at 03:31:00 UTC, 09:31.00 UTC, 15:31:00 UTC, 21:31:00 UTC.
[Timer]
*-*-* 03:31:00 UTC mais aussi 09:31.00 UTC, 15:31:00 UTC et 21:31:00 UTC
[Install]
WantedBy=timers.target |
Dernière chose j'aimerais que le service s'arrête des que le script a fini de bosser
Merci de m'éclairer sur le sujet ;)