1

When I run my bash script manually via terminal (bashscript.sh) calling youtube-dl then youtube-dl is found and executed. When running via cron my log says :

/home/myhomepath/bashscript.sh: line 5: youtube-dl: command not found

My entry made by using crontab (Note: used crontab -e to input the entry and the interval to run the script is just made up for example purposes)

*/1 * * * * /home/myhomepath/bashscript.sh 

Inside my bash script I've tried using the following at the top:

#!/usr/bin/env bash and also #!/usr/bin/bash but neither resolve the issue

I call youtube-dl in the script by the following:

 youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' --download-archive downloaded.txt --no-post-overwrites -o '/path/im/writing/to/'$RESULT 'http://youtube.com/watch?v='$RESULT

The binary is located here:

/usr/local/bin/youtube-dl

I've also tried updating youtube-dl to the latest version, but that doesn't resolve the issue. Command used:

pip install --upgrade youtube-dl
Kristen
  • 39
  • 5
  • Replace `youtube-dl` with `/usr/local/bin/youtube-dl`. – Cyrus Nov 01 '18 at 19:00
  • See ["How to get CRON to call in the correct PATHs"](https://stackoverflow.com/questions/2388087/how-to-get-cron-to-call-in-the-correct-paths) and ["Why is the cron ENV different from the user's ENV?"](https://serverfault.com/questions/698577/why-is-the-cron-env-different-from-the-users-env) – Gordon Davisson Nov 01 '18 at 19:09

1 Answers1

1

Per Cyrus above in the comments section: Replace youtube-dl with /usr/local/bin/youtube-dl.

Kristen
  • 39
  • 5