williamZanelli Posted May 2, 2009 Share Posted May 2, 2009 Hi guys, I have a PHP file, that needs to be called evry 2 mins, to check to see some external servers data has been updated. Eg. The following file needs to be called, dataupdater.php with some parameters. mywebsite.com/dataupdater.php?item=1 mywebsite.com/dataupdater.php?item=2 mywebsite.com/dataupdater.php?item=3 mywebsite.com/dataupdater.php?item=4 mywebsite.com/dataupdater.php?item=5 mywebsite.com/dataupdater.php?item=6 If the data is updated I update my DB. Could some please tell me the best way of calling "dataupdater.php?item=6" ie. should it be a daemon thread, Cron job, WGET etc.. or should I create a PHP file, containing a thread, which sleeps for 2 minutes then calls dataupdater.php?? The file to be called is stored locally, but has will connect to some external XML file to check if the data status. I want something that is efficicient, fast and relaiable. Hope this question makes sense thanks in advance for your thoughts, Will Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 2, 2009 Share Posted May 2, 2009 Use CRON. Quote Link to comment Share on other sites More sharing options...
williamZanelli Posted May 2, 2009 Author Share Posted May 2, 2009 Thanks for the reply!! Using cron, how do I call a local file? I tried using WGET, problem with that is.. it uses http:// protocol then, which slows down everything. Any ideas? Thanks in advance for your thoughts. Will Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 2, 2009 Share Posted May 2, 2009 Sounds more like you have no idea what CRON is. I suggest Google. Quote Link to comment Share on other sites More sharing options...
DjMikeS Posted May 3, 2009 Share Posted May 3, 2009 And you need to have the php CLI installed... If you have Debian, just do: #sudo apt-get install php5-cli Then in your cron, call the file like: php /var/phpfile.php Quote Link to comment Share on other sites More sharing options...
williamZanelli Posted May 3, 2009 Author Share Posted May 3, 2009 Thanks for the reply guys. Just out of intrest, how would running a continuous thread in the background do? Is it an acceptable programming practise? Or are there some issues I've not conisdered? Thanks for your help Will Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 Well running a script non-stop can cause heavy load issues, depending on what the script is doing. But it can be very extensive. Quote Link to comment Share on other sites More sharing options...
williamZanelli Posted May 3, 2009 Author Share Posted May 3, 2009 Well, basically what Im trying to achieve is, every few minutes oto check if some external XML file has been updated, if it has, I take the "new data" and store it in my database. Hence why I would like to call some local PHP file, that will do the checking. I'd say there's around 150 XML files to be checked every 30 minutes. The script that runs is the same, the varible iten "dataupdater.php?item=6" dictates which XML file to check. Whats the best way of doing this? Thanks for your help thus far Will PS: I have a dedicated host, which goes some way in giving me flexiibility as to my method of coding this. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 Well, as long as you have enough bandwidth for that, go for it! Quote Link to comment 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.