0

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
kjakeb
  • 263
  • Give a look to this answer: http://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work – enzotib Aug 08 '11 at 06:40

2 Answers2

1

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)

0

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.

shellter
  • 325
  • 2
  • 10