This is a discussion on "scheduled asp script" within the Classic ASP section. This forum, and the thread "scheduled asp script are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
scheduled asp script
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
scheduled asp script
Hi,
Is is possible to run an asp sever script according to a schedule rather than being invoked by a browser request? Here's why (any alternative suggestions welcome): I am building an ecommerce site where the product supplier provides access to a text document containing all currently out of stock items. The text document is updated hourly. I want to be able to run a script every hour which updates a column in my product database so that none of the products with 0 in the stock column are returned in my queries. Because of the paging of products, it would be better if products are not in the recordsets when querying the database (rather than trying to remove or skip records after the database has been queried). I can simply invoke the script every time somebody visits the homepage for example, but I'd rather not put this burdon on the server when the user will be waiting for the page to be served. It would be better if the database is continuously updated every hour without the need for interaction from a site user. Any thoughts? |
|
|
|
|||
|
The burdon is going to have to be on something! I have in the past created an .vbs file which launches internet explorer on the server and goes to a specific page, this page performs my database tasks. The vbs file is set to run everyday using Windows built-in task scheduler. I think that would be a solution for you, heres the vbs code:
|
|
|||
|
ok, but my site is hosted on shared hosting space, won't this prohibit me running processes such as this? I'm afraid I'm a newby as regards vbs applications and client side scripts. My asp knowledge only stretches into its implementation on web pages as server side scripting.
I've also just discoved that I have a problem reading the .csv file on the product suppliers site using the asp fso object. I think it is something to do with permisions at their end, but I can't speak to anybody there until monday. All a bit belly up really, but thanks. |
|
|||
|
in that case the .vbs and task scheduler will have to run on your computer or a server that you have full control over.
|
|
|||
|
hmm. right. I'll have a think.
Thanks for all your help. |
|
|||
|
Smokie's suggestion is the usual way this is done.
|
|
||||
|
Let me make an alternaive suggestion....
The text file (containing out of date stock items) should be placed in a directory and queried everytime a product SELECTtion (from the database) is performed. Now whilst that may sound pretty slow we are actually only talking about milliseconds here so the 'slow' will likely be mostly unnoticeable. My suggestion would be to read the text document: perform the needed action to mark products out of stock in the DB and then... delete the text file. Every time a product SELECTion is needed, just see if that file exists, if it doesnt, do nothing.... if it does, then do yer stuff. Just a suggestion.
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
Doesn't windows hosting have anything similiar to Unix's cron?
|
|
|||
|
the closest thing to cron is the windows task scheduler and typically microsoft didnt make it web friendly on their webserver products... Some webhosts do offer asp scheduling (crystaltech) but its pretty rare AFAIK. Robs sugesstion is the cleanest.
|
|
||||
|
Quote:
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
Hate to not be offering help... but this is VERY usefull information to me, I just stumbled across this same problem. Thanks guys
|
|
|||
|
Sorry about the delay in replying. I've been tring to get hold of the company which holds the text file on their server.
I agree with everything you guys have said (thanks), and will run some script to update the database at those times when a SELECTion is made (as Rob suggested), rather than trying to schedule the script. The problem at the moment is that the text file containing the info is on the suppliers server, and I haven't managed to read from it using my asp fso object. I just get a "file cannot be found" message. I gather that reading remote files often fails because of permissions on the source file. I am waiting to hear back from the technical guys at the supplier about this. If anybody has anymore pointers about reading remote text files using the fso, or if there is a method by which I can automatically copy the remote file onto my server so that I can read it from there, I would be grateful. Thanks again to all! |
|
|||
|
i think you'll need to use Microsoft's ServerXMLHTTP component (should already be available on your server) to grab the text file, this example should get you started:
|
|
|||
|
ah right...
Cheers man. I'll have a go with this. |
|
|||
|
wow! brilliant. This looks to be just what I need. Cheers smokie.
|
|
|||
|
Thanks guys, all sorted now.
I've ended up with a script which sets an application variable which keeps track of when the last update was performed. The overall script is run everytime somebody queries the database, but the update based on the remote text file is only performed in my database if the application variable was set more than an hour ago. This means that I can guarantee that the database is never more than one hour out of date, but that the script isn't run more than once an hour. Heres my final script for anybody who's interested
|
![]() |
| Tags |
| scheduled, asp, script |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with this script | korvix | JavaScript Forum | 1 | May 28th, 2008 23:00 |
| Just following the script... | chrisomatix | Introduce Yourself | 3 | Feb 27th, 2008 07:03 |
| Js Ad Script | laffin | JavaScript Forum | 0 | Nov 28th, 2007 10:13 |
| script help | ehud36new | JavaScript Forum | 2 | Nov 13th, 2007 13:15 |
| Changes to CSS script | Accurax | Web Page Design | 6 | Dec 17th, 2006 16:36 |