You are here:  » Cronjob with slow import


Cronjob with slow import

Submitted by nanaz on Tue, 2017-02-14 13:09 in

Hi David,

Hope you are well!

When I use cron.php in a cronjob not all records are imported, because - as I understand it - cron.php imports, not Slow imports feeds. Most of my feeds are >500 records and these are only partially imported with cron.php. Smaller feeds are imported correctly.

A the moment I use a cronjob for fetching all feeds (with fetch.php @ALL), and in the morning I manually push the ‘Slow Import’ button in the admin and all records will be imported correctly. Then I run featuredcheck.php through the browser.

It’s not ideal but it works, but could there be a way to make cron.php work so I can automate it all? If it’s a server configuration I'm sure I can change it. I've searched for an answer on the forum but can't find it.

Thank you,

Kind regards, Marlies

Submitted by support on Tue, 2017-02-14 14:00

Hello Marlies,

The slow import method is not really suitable for CRON activation due to the HTTP / Refresh mechanism through which it is implemented. However, it sounds like either one of two things is occurring, both of which you should be able to resolve through configuration or simple edits.

In most server configurations there are separate php.ini files for PHP as an Apache module, and the command line version. Whilst it is sensible for the Apache module instance to have a maximum execution time set, it sounds like (if this is the case), your server also has a maximum execution time for command line PHP, and therefore stopping cron.php before it has completed. Typically, the configuration files might be something like

/etc/php5/apache/php.ini
/etc/php5/cli/php.ini

In this case, it would be the cli/php.ini instance in which you would need to check for a max_execution_time directive, and it set, change to 0 for unlimited execution time.

If that doesn't appear to be the case, the other possibility is that your server has a resource usage monitor in place and is terminating any process that exceeds certain thresholds such as processor utilisation. The reason I am wondering if this is the case here is because you mentioned that fetching all feeds works OK - which is not processor intensive, whereas importing on the other hand, is.

In this scenario, the 1 second sleep between every 100 products imported modification from this comment significantly reduces processor usage of php / cron.php which should do the trick otherwise...

Cheers,
David.
--
PriceTapestry.com

Submitted by nanaz on Tue, 2017-02-14 19:28

Hi David,

I've tried both solutions you suggested, but no luck: changed the max. execution time and inserted the 1 second wait in admin.php. I forgot to mention when I use the "Import" button in the admin I get the same, incomplete result as with the cronjob.

This PT site has 41 feeds which totals 8.000 records (some contain just 4 to 10 records, others max. 900), so it's not much.

Also: when I try to "Import" just one feed (900 records) in the admin, 0 records are returned. A single feed of 400 records imports okay. "Import all" will result in sometimes 0 and sometimes a part of the records of every larger feed, small feeds are okay.

I can contact my provider, but I'm not sure what to ask them. Hope you can help!

Kind regards, Marlies

Submitted by support on Wed, 2017-02-15 09:52

Hello Marlies,

That sounds like a more fundamental issue rather than anything timing out - in the first instance please could you email me includes/admin.php from this installation and I'll pick it up from there with you...

Cheers,
David.
--
PriceTapestry.com