views:

24

answers:

1

Hi. I want to be able to in some way "quee" operations on Apache web server with PHP. For example I want to create a loop like this:

<?php
foreach($files as $key=>$value){
 download($value);
}
?>

The "download" function just runs wget and downloads the file to a specified position. This is working OK but my problem is that during this operation, I can't do anything else until the files are downloaded. In other words, what i am trying to do is to have the download function run in the background (using another Apache thread or something), letting me move around and do other things on my site.

How can I do this?

A: 

The simplest way is to keep the queue in a database table and have a cron job that reads tasks from that table and executes them. Assuming your host supports cron jobs - if not, make a "fake" cron page and call it periodically from your computer, using task scheduler or whatever.

stereofrog