1

This is my sh-file: http://paste.ubuntu.com/5816543/, that I use this to download youtube files in a specific period per day. when I drag the file (y.sh) into the terminal and press return key, it starts to download. but when I use the below command in crontab -e, Nothing happens!

00 21 * * * /home/deroot/links4dl/y.sh

Torify: wrapper for torsocks or tsocks and tor -> man torify

youtube-dl: download videos from youtube.com or other video platforms -> man youtube-dl

5
  • 2
    if any of those commands post output to the screen it is NOT going to work. I would ALWAYS reroute errors and notices to /dev/null 2>&1
    – Rinzwind
    Jul 1, 2013 at 12:01
  • 1
    Also, always use the full path when using crontab. That, or make sure that the shell running the script has the same $PATH variable as your interactive bash session.
    – January
    Jul 1, 2013 at 12:08
  • 1
    And if you do not use an absolute path add $PATH to your crontab ;) example: stackoverflow.com/questions/10129381/crontab-path-and-user
    – Rinzwind
    Jul 1, 2013 at 12:10
  • Or, you can try redirecting the output to a file, so you can see the errors. So, you would do 00 21 * * * /home/deroot/links4dl/y.sh > /home/deroot/ScriptLog
    – Alaa Ali
    Jul 1, 2013 at 13:04
  • 2
    @Alaa 00 21 * * * /home/deroot/links4dl/y.sh > /home/deroot/ScriptLog 2>&1
    – Emmanuel
    Jul 1, 2013 at 14:07

1 Answer 1

2

Remember that Cron uses its own environment, which is different of your own environment.

If you didn't changed it, in cron environment $PATH is /usr/bin:/bin

You can check where your command are stored with that commands:

which torify 
which youtube-dl

if its not in /usr/bin:/bin => Add a minimal PATH environment into your script, something like:

export PATH="/bin:/usr/bin:xxxx"

(where xxxx is the path to your command )

1
  • note that @Rinzwind pointed that you can add the PATH to the crontab itself.
    – Emmanuel
    Jul 1, 2013 at 18:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .