Using AT on Ubuntu to Background Downloads (w/ Queue)
- by Nicholas Yost
I am writing a PHP script, but I want to use the AT command in Ubuntu to fetch a remote file via WGET. I'm basically looking to background the process, so PHP can finish fairly quickly.
I cannot find any questions on here about how to use both, but I basically want to do the following pseudo-code:
<?php
exec('at now -q queuename wget http://path.to/remote/file.ext');
?>
Additionally, I'd like to queue this between providers. I'd like to have each path.to have its own queue, so I only download one file from each provider at a time. Meaning:
<?php
exec('at now -q remote wget http://path.to/remote/file.ext /local/path');
exec('at now -q vendorone wget http://vendor.one/remote/file.ext /local/path');
exec('at now -q vendortwo wget http://vendor.two/remote/file.ext /local/path');
exec('at now -q vendorone wget http://vendor.one/remote/file.ext /local/path');
?>
This should download the files from path.to, vendor.one, vendor.two immediately, and when the first file is finished downloading from vendor.one, it starts the second file.
Does that make sense? I can't find anything like this anywhere on the web, much less on SO/SF. If we can use the crontab to run a one-off wget command, thats fine too.