Executer un script bash par cronjob ne fonctionne pas.

Résolu/Fermé
guillaumegilbertsoucy Messages postés 326 Date d'inscription vendredi 11 octobre 2013 Statut Membre Dernière intervention 4 juillet 2023 - 3 oct. 2021 à 17:31
guillaumegilbertsoucy Messages postés 326 Date d'inscription vendredi 11 octobre 2013 Statut Membre Dernière intervention 4 juillet 2023 - 4 oct. 2021 à 20:17
Bonjour,

J’essaie de faire en sorte qu'un cronjob exécute un script bash .sh à tous les heures mais ça ne fonctionne pas.

Tous les tutoriels que j'ai lus qui sont supposer fonctionner ne fonctionne pas pour moi.

Ça c'est un de mes scripts bash:

#!/bin/bash

timeout 3600 youtube-dl --no-part https://bcovlive-a.akamaihd.net/575d86160eb143458d51f7ab187a4e68/us-east-1/6101674910001/playlist.m3u8 -o /mnt/disk/iptv/Canada/Télé_Québec/Télé_Québec_`date +%Y-%m-%d_%H:%M:%S`.mp4


Mon crontab:

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
#
0 0 * * * fstrim -a
0 0 * * * apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoremove -y >/dev/null 2>&1
#
0 0 * * * find /mnt/disk/iptv/* -mtime +1 -exec rm -rf {} \;
#
0 * * * * /bin/bash /mnt/disk/scripts/Canada/Tele_Quebec.sh >/dev/null 2>&1
0 * * * * /bin/bash /mnt/disk/scripts/Canada/ICI_RDI.sh >/dev/null 2>&1
0 * * * * /bin/bash /mnt/disk/scripts/Canada/ICI_Tele_HD.sh >/dev/null 2>&1
0 * * * * /bin/bash /mnt/disk/scripts/Canada/TVA.sh >/dev/null 2>&1


J'ai une partie de log ici:

Oct  3 15:00:01 iptv-dc CRON[20896]: (root) CMD (/bin/bash /mnt/disk/scripts/Canada/Tele_Quebec.sh >/dev/null 2>&1)
Oct 3 15:00:01 iptv-dc CRON[20897]: (root) CMD (/bin/bash /mnt/disk/scripts/Canada/ICI_RDI.sh >/dev/null 2>&1)
Oct 3 15:00:01 iptv-dc CRON[20898]: (root) CMD (/bin/bash /mnt/disk/scripts/Canada/TVA.sh >/dev/null 2>&1)
Oct 3 15:00:01 iptv-dc CRON[20902]: (root) CMD (/bin/bash /mnt/disk/scripts/Canada/ICI_Tele_HD.sh >/dev/null 2>&1)


Comme je le disait, tous les tutoriels que j'ai lus ne semble pas fonctionner dans mon cas.

Lorsque exécuté manuellement, mes scripts bash fonctionne sans problème. Mes fichiers .sh sont exécutable.

Merci pour de l'aide.

Guillaume

3 réponses

dubcek Messages postés 18718 Date d'inscription lundi 15 janvier 2007 Statut Contributeur Dernière intervention 22 mars 2024 5 615
4 oct. 2021 à 11:04
hello
récupérer d'éventuels messages d'erreur
0 * * * * /bin/bash /mnt/disk/scripts/Canada/Tele_Quebec.sh >/tmp/log1 2>&1
1
guillaumegilbertsoucy Messages postés 326 Date d'inscription vendredi 11 octobre 2013 Statut Membre Dernière intervention 4 juillet 2023 8
Modifié le 4 oct. 2021 à 14:08
Oui le fichier log1 dit:

timeout: failed to run command ‘youtube-dl’: No such file or directory


Faudrait mettre le chemin direct vers youtube-dl

J’essaie et je post le résultat ici.

Merci,

Guillaume
0
guillaumegilbertsoucy Messages postés 326 Date d'inscription vendredi 11 octobre 2013 Statut Membre Dernière intervention 4 juillet 2023 8
4 oct. 2021 à 20:17
Salut,

Oui c’était ça, il fallait mettre le chemin vers youtube-dl dans le fichier script.

Maintenant le script est exécuté toute les heures.

Merci!!!

Guillaume
0