My question is, how would one go about setting up a task to run nightly?

The problem at hand is, company A stores data on company B's server. Then nightly, company B creates an XML feed for them to take the updates and put them in there own database server (that I am going to set up). The website never sends updates back, the only updates from company A are from inside there office system.

So, what I have to do is take this XML feed and put it in my own server. It could be a fairly large number of records (500 maybe) - So I'm not sure how fast it could realistically be parsed through and then added to the database.

How do I go about this without checking each time a user visits the website? It needs to be automatic too, rather than somebody going to the specific page each night and clicking 'go'.

    Theres a few things you could be doing here. Windows servers have the Scheduled Tasks wizard, and Unix has Cron. Both can be used to trigger a PHP script at a particular time.

    The other option could be to use the scheduler in your database. SQL Server has a built in scheduler, and by the look of it MySQL has one in the works.

    Given the complexity of the task it would probably make more sense to use the first option.

    Incidentally the PHP script will be run as a command line program rather than through the webserver, so timeouts shouldn't be a problem.

      OK, cool. Thanks.

      The one concern is, the company I'm freelancing for may be giving me a share hosting option and no doubt on Apache. So I may not have access to these features.

        If they're on apache with a professional server, chances are it's on a *nix platform - it just runs better on Linux than Windows, and IIS is what professional windows servers run, most of the time.

        Talk to your client, and find out if they're running Linux, and if they have shell access/an option in their control panel (Cpanel does, I know, and I think Plesk does too) to schedule tasks.

          Write a Reply...