PDA

View Full Version : crontab problems



mvalviar
October 31st, 2009, 11:51 PM
Hi! I'm trying to run a php script that accesses files that are relative to the location of the script. When I run it manually it runs fine. But when cron runs it the script yells with can't find file.

I've already read that its something about cron not setting up the environment

I tried

MAILTO=me
PWD=/home/me/path/to/script
* * * * * $HOME/path/to/script/myscript.php

but it doesn't work.

Sporkman
November 1st, 2009, 04:18 AM
Hi! I'm trying to run a php script that accesses files that are relative to the location of the script. When I run it manually it runs fine. But when cron runs it the script yells with can't find file.

I've already read that its something about cron not setting up the environment

I tried

MAILTO=me
PWD=/home/me/path/to/script
* * * * * $HOME/path/to/script/myscript.php

but it doesn't work.

Not sure, but you might need to explicitly set the entire absolute path, instead of assuming that HOME is set.

mvalviar
November 1st, 2009, 06:33 AM
I already tried that before. Even specifiying the absolute path to doesnt' seem to help.

Sporkman
November 1st, 2009, 02:14 PM
I already tried that before. Even specifiying the absolute path to doesnt' seem to help.

A couple of other things: I'm not sure that defining those other variables is the right thing to do in terms of what should be in a crontab script - i.e. it's not a regular shell script.

Also: You have '*' for every interval parameter, so that says you want it to run every minute, is that correct?

Here's a crontab tutorial:

http://ubuntuforums.org/showthread.php?t=102626