Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
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 '13 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 '13 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 '13 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 Jul 1 '13 at 13:04
2  
@Alaa 00 21 * * * /home/deroot/links4dl/y.sh > /home/deroot/ScriptLog 2>&1 –  Emmanuel Jul 1 '13 at 14:07
add comment

1 Answer 1

up vote 2 down vote accepted

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 )

share|improve this answer
    
note that @Rinzwind pointed that you can add the PATH to the crontab itself. –  Emmanuel Jul 1 '13 at 18:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.