ASP classic: How to schedule a function server-side

天大地大妈咪最大 提交于 2019-12-05 22:58:05

If you have access to the server, create a vbscript (.vbs) and setup the Task Scheduler...

This is what we use for database tidy routines and for nightly backups.

You can schedule jobs through free cron services such as https://www.setcronjob.com with configuration like in following picture. This is a good solution for hosting customers who do not have permission to create the task, I used many times with no trouble. The service will request to url you specified at you specified timespan or exact time.
For a little bit security / avoiding unnecessary requests you could specify a custom hash for the will be requested page.

If Request.QueryString("hash") = "somespecialstuffs" Then
    'Do Job
End If

if you don't have access to the servers, as a work-around you can do the following... Create a task in your server (anything that runs 24 hours), and that task will just visit your site to a specific ASP page with a parameter that instructs it to do the update, so create an ASP file that reads the parameter and runs the update.

The problem with putting it in global.asa is that, if your site is not constantly in use, IIS could stop the application process after some time (think the default in IIS is like 30 minutes), so you're not guaranteed that the application process will be up to run the update.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!