You are here:  » import.php won't run from a cron job

Support Forum



import.php won't run from a cron job

Submitted by tbbd2007 on Thu, 2007-10-25 15:47 in

David

I have a managed server with 1&1, but I can't seem to get import.php to run as a Cron Job even though it will run manually from PuTTY. I have used both /usr/local/bin/php -f /homepages/*/****/htdocs/uk_directory/online_shopping/scripts/import.php @MODIFIED and /usr/local/bin/php /homepages/*/****/htdocs/uk_directory/online_shopping/scripts/import.php @MODIFIED, but to no avail.

Thanks

Stephen
The Big Business Directory
www.the-big-business-directory.com
www.the-big-business-directory.co.uk

Submitted by support on Thu, 2007-10-25 16:23

Hi Stephen,

There are 2 possibilities here.

Firstly, the directory in which CRON is running from. Depending on the version of the command line PHP binary, it may or may not change directory to that of the script. It is best to be sure by adding a cd command infront of the command to execute the script. A semi-colon separates commands, so you could try this as your CRON entry:

cd /homepages/*/****/htdocs/uk_directory/online_shopping/scripts/;/usr/local/bin/php import.php @MODIFIED

If that doesn't work, the second most likely issue is a permissions problem. If CRON isn't running as root, it may not have access to the online_shopping/ directory (and more critically the /scripts and /feeds sub-directories). To resolve this you should be able to check the permissions using your FTP program, by viewing properties on the directories in the remote window. Look for the words "Owner | Group | World" together with a list of access rights, and see if "World" read is set for these directories. Then check all the way up the tree, as every parent directory must also be world-read for CRON to have access to the files...

Hope this points you in the right direction...

Cheers,
David.

Submitted by tbbd2007 on Thu, 2007-11-08 07:15

David,

I have tried the things you have mentioned, to no avail. I have been changing various file and folder permissions, but can't find anything that works. What should the folder and file permissions be set to in Unix code?

Thanks

Stephen
The Big Business Directory
www.the-big-business-directory.com
www.the-big-business-directory.co.uk

Submitted by support on Thu, 2007-11-08 09:21

Hi Stephen,

They need to be readable by the user that cron is running as. If you don't know what user it is running as, the easiest way is to make the world readable, which is "777" if using the chmod command. If you have done that it implies that something else is the problem rather than permissions.

Most cron systems provide a results output - do you have anything that you can look at to indicate what might be going wrong? If you're using the Plesk control panel I think this is an option you can select - so if you're able to choose this you might get an informative error message from CRON which should indicate why it is unable to execute the script...

Cheers,
David.

Submitted by tbbd2007 on Thu, 2007-11-08 11:40

David,

I have actually now discovered the error my changing around items to test them in the crontab file. I had actually go the hours and minutes round the wrong way, import was actually trying to run a few minutes into a download rather than a few hours after.

Sorry for the confusion!

Stephen
The Big Business Directory
www.the-big-business-directory.com
www.the-big-business-directory.co.uk