LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cronjob not working but script works (https://www.linuxquestions.org/questions/linux-newbie-8/cronjob-not-working-but-script-works-295731/)

dtra 02-28-2005 12:33 AM

cronjob not working but script works
 
hi all

i've got this strange problem
i'm using red hat 9
php5
mysql 4.1.7

i wrote a script to reset some mysql tables and rename them
from the command line

then i put in an executable text file
Code:

cd /usr/bin
php /path/to/resetmonth.php

saved that as resetmonth

i can run it from the command line with ./resetmonth
and the tables update properly

but when i set the cron job as
Code:

0 0 1 * * /path/to/resetmonth
change the date to just before the end of the month
but it doesn't do anything (could it be changing the date like that?)

i have another cron job that runs every day
and uses the same code in the exe text file, and that works

can anyone give me a clue as to what the problem might be

thanks
dave

jailbait 02-28-2005 11:16 AM

Check the permissions on your executable script file. You may have it executable as user but not executable as root.

---------------------------
Steve Stites

dwight1 02-28-2005 11:21 AM

You might want to change the "php" line to use an absolute path. E.g. /usr/bin/php, if that's where php lives on your system.

dtra 02-28-2005 04:35 PM

hey, thanks guys for your replies
but unfortunately they didn't solve the problem
the script and exe have the same permissions as the other one
which runs fine
and the path is the same as well

the problem is that the php script runs fine when run from the exe from the command line
i guess the only difference is that one php script runs using a local database (doesn't work from cron)
and the other one runs using a remote database (does work)

any other ideas

dwight1 02-28-2005 05:05 PM

Perhaps it's something with the standard file descriptors (stdin, stdout, stderr)? That's just speculation, but it's one thing which is different from running it from a shell.

Try sticking a /usr/bin/strace -f /usr/bin/php ... in there instead.

The drawback here is that there will be a lot of output, but cron should just email it to you. The output from strace should give you an idea as to what's failing.


All times are GMT -5. The time now is 05:14 PM.