Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have this shell script at /usr/local/1.sh:

#!/bin/sh
wget -r -np --user=peter --password='123' ftp://67.225.87.95/ -p /test/

If I run it using

# sh 1.sh 

the script executes ok and does what its supposed to do.

But if I create a cron job to execute the exact same script:

1 2 * * * /usr/local/bin/1.sh

the script is not executed at all.

What could be wrong?

share|improve this question
    
How the hell did you manage to add multiple lines in your title? –  SamK Jul 25 '11 at 9:56
    
What do you mean by "shell script not done"? Is there any error message? –  vstm Jul 25 '11 at 10:07
    
SamKrieg: "wget shell script" is the title. He has just made three lines of which are headline highlighted. –  rzetterberg Jul 25 '11 at 10:08
    
Check if wget is in the PATH of the user, whose crontab you are using. –  HUB Jul 25 '11 at 10:11

3 Answers 3

  • Always use the full path when doing something in cron job
  • Redirect all the output, error to a log file to see what happen: 1 2 * * * /usr/local/bin/1.sh > /var/log/1.log 2>&1
share|improve this answer

If you are going run it directly without invoking the shell interprer, you need to provide the appropriate permissions:

chmod +x /usr/local/bin/1.sh

Otherwise, run the interpreter against its:

1 2 * * * /bin/sh /usr/local/bin/1.sh
share|improve this answer

Replace:

1 2 * * * /usr/local/bin/1.sh

By:

1 2 * * * /bin/bash /usr/local/bin/1.sh

or

Keep it:

1 2 * * * /usr/local/bin/1.sh

And prepend the following to /usr/local/bin/1.sh:

#!/bin/bash

(you may need to replace /bin/bash by whatever which bash is telling you)

share|improve this answer

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.