homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

Cron Job PHP Problem
...what's wrong?

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

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)

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)

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)

or just run the script with:

lynx [localhost...]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved