lovingboth: (Default)
[personal profile] lovingboth
I want one of my websites to get data from another website. Every 12 hours, cron will run a PHP script to snaffle it and stick it in a database for later use.

Sometimes, for whatever reason, the snaffle may not work. (The other site may be down, or busy or there may be routing problems or whatever.)

The obvious thing to do is say 'try snaffling until success', but I'm reluctant to alter the php.ini setting that says scripts run for a max of 30 seconds, so...

... is there a good alternative to having a PHP script that says in effect
Is the data already snaffled?
If not, get it.

and getting cron to run this at, say, 00:00, 00:15, 00:30, 00:45 to give four chances of a successful snaffle? The check would be a really quick SQL query, so if it succeeded the first time, the subsequent runs would be very short.

(no subject)

Date: 2004-06-11 07:32 am (UTC)
From: [identity profile] fruit-boy.livejournal.com
A completely different solution would be to have the script run every 5 minutes and to first check a control file for the last time data was sucessfully snaffled. If this is less than 24 hours ago then simply exit. If not, attempt to snaffle data and if sucessful write the current time back to the control file.

Profile

lovingboth: (Default)
Ian

March 2026

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags