theITvideos Posted November 1, 2010 Share Posted November 1, 2010 Hi there, I am working on a php project on my WAMP server where I have access to XML datafeed from xe.com once a day to get the Exchange rates. This xml datafeed is saved on my localhost as an archived copy. Now I would like to automatically access the fresh xml datafeed file from xe.com once a day and replace (or update) the xml file on my localhost to have the updated information (rates). How can I schedule this task automatically and make php access the updated xml file once a day. All comments and feedbacks are always welcomed Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/217400-running-an-automatic-schedule-task-in-php/ Share on other sites More sharing options...
trq Posted November 1, 2010 Share Posted November 1, 2010 You need to use the OS's scheduler program. In the case, Windows Scheduler on Linux you would use Cron. This really has nothing to do with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/217400-running-an-automatic-schedule-task-in-php/#findComment-1128832 Share on other sites More sharing options...
theITvideos Posted November 1, 2010 Author Share Posted November 1, 2010 You need to use the OS's scheduler program. In the case, Windows Scheduler on Linux you would use Cron. This really has nothing to do with PHP. Glad to hear from you. So now I have tried my hands on windows scheduler. I can created a simple task that just displays a test msg (just to see if it is working.) Now how do I write a php script that will get the updated xml data from a link i.e: http://mydomain.com/TheUpdatedxmlFile.xml and update the old xml file residing on my localhost. And once I can get the update script, then in the Windows Scheduler I can set it to 'once a day' coz I am allowed to access the new xml file only once in a day. Now i can take care of the scheduling part, it is just the php script (or code) that I need that will automate the process of getting the updated xml file. (Basically to replace the old xml file with the new one from the link) Please reply. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/217400-running-an-automatic-schedule-task-in-php/#findComment-1128840 Share on other sites More sharing options...
trq Posted November 1, 2010 Share Posted November 1, 2010 <?php $new = file_get_contents('http://mydomain.com/TheUpdatedxmlFile.xml'); file_put_contents('/path/to/old/file.xml', $new); Quote Link to comment https://forums.phpfreaks.com/topic/217400-running-an-automatic-schedule-task-in-php/#findComment-1128851 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.