Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-28-2005, 12:33 AM   #1
Registered: Nov 2004
Distribution: fc4
Posts: 104

Rep: Reputation: 15
cronjob not working but script works

hi all

i've got this strange problem
i'm using red hat 9
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
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
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

Old 02-28-2005, 11:16 AM   #2
LQ Guru
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,346

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

Steve Stites
Old 02-28-2005, 11:21 AM   #3
Registered: Feb 2005
Posts: 42

Rep: Reputation: 15
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.
Old 02-28-2005, 04:35 PM   #4
Registered: Nov 2004
Distribution: fc4
Posts: 104

Original Poster
Rep: Reputation: 15
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
Old 02-28-2005, 05:05 PM   #5
Registered: Feb 2005
Posts: 42

Rep: Reputation: 15
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Call of Duty 2 Cronjob Not working zend Linux - Software 3 11-15-2005 10:52 AM
Shell script works on RH 7.2 but not on RH ES brian Red Hat 1 08-31-2004 11:55 AM
Starting Firefox (script that just works) Halcyon-X Linux - General 11 08-26-2004 09:31 PM
Only test.cgi script works? lonny Programming 1 12-09-2003 08:38 PM
Script works on Redhat but not on Slack Kocil Slackware 3 07-18-2003 12:03 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration