Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

Cron Job PHP Problem

...what's wrong?



4:48 pm on Sep 3, 2005 (gmt 0)

10+ Year Member

Hi guys,

I set up a cron job to execute a PHP script that writes a file and it isn't working. I can't tell if the cron job itself or the PHP script is failing.

If I type this on the command line it works fine:

php /usr/www/myname/mysite/jobs/main.php

...and here is my crontab entry (for testing):

* * * * * php /usr/www/myname/mysite/jobs/main.php

...which seems fine.

One thing I can think of is the path to the file in the PHP code. I gave it the full path like so:


Since it's getting called in the crontab maybe I have to do something different? What about the permissions for the main.php file, does that need anything special? Like I said, it works on the command line so I don't know what I could be doing wrong.



9:00 pm on Sep 4, 2005 (gmt 0)

10+ Year Member

Hi Emperor,

just two things to check first:
-1- the crontab-user may not have the same environment as you have when testing and running the /your/path/to/php command, so you would be on the safe side to specify the full path of the php interpreter in the crontab.
-2- the permissions of the main.php file may be important or not, depending on the file-ownership of the main.php (and the directory above) and its relation to the crontab-user.



4:38 pm on Sep 7, 2005 (gmt 0)

10+ Year Member

Yeah, most likely its a path issue, try adding the path to php and add the -q switch. Example:

/usr/bin/php -q /usr/www/myname/mysite/jobs/main.php


3:44 pm on Sep 20, 2005 (gmt 0)

10+ Year Member

or just run the script with:

lynx [localhost...]


Featured Threads

Hot Threads This Week

Hot Threads This Month