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.

Possible Duplicate:
Reasons why crontab does not work

I have setup a crontab to run a shell script every minute. Here's my crontab file:

* * * * * sh /var/www/stuff/public_html/recycle.sh

This crontab fails to run at all, but if I run the shell script by itself it works perfect. Can anyone explain why this might be happening? Other potentially useful info:

  • OS: Ubuntu 10.04
  • User running the crontab: root
share|improve this question
    
Give a look to this answer: askubuntu.com/questions/23009/reasons-why-crontab-does-not-work –  enzotib Aug 8 '11 at 6:40
add comment

migrated from stackoverflow.com Aug 8 '11 at 3:39

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Javier Rivera, jrg Feb 27 '12 at 21:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

It could be a permissions issue?

Also - try adding in a email address to the script so that any output (errors etc.) is emailed to you.

You can do this by adding: MAILTO=someone@somewhere.com

EDIT: I see you are running as root, missed that before....

Is it possible that the script is using enrionment variables that root does not have? ie. instead of using 'python' you might want to use /bin/python (or whatever it is)

share|improve this answer
add comment

Look for email messages in the root email account.

maybe you really want

\* \* \* \* \* sh -c "/var/www/stuff/public_html/recycle.sh"

I think the whole "sh -c" is probably redundant, so just try it with the command /var/www.....

Better yet, capture the output, then you know it ran And you are capture stdout/stderr to a file for later inscepction.

\* \* \* \* \* sh /var/www/stuff/public_html/recycle.sh > /tmp/myProj/recycle_sh.trace_log 2>&1

Some crontabs understand a seperate line at the top like

MAILTO=myuser@my.com

I hope this helps.

share|improve this answer
add comment