I want to run a script that writes information to the database every 24 hours. I am not the administrator of the server, so I do not have access to Scheduled Tasks
, I read in some articles that I can use Global.asa
for every time the site is visited (using Session_OnStart), count 24 hours and run the script. / p>
I tried to apply this form but it did not work; Here is the code in classic asp:
<!-- #include file="etc/conexao.asp" -->
<script language="vbscript" runat="server">
Sub Session_OnStart
'Runs on application start or after 15 minutes
If Application("LastRun") = "" Or DateDiff(n, Application("LastRun"), Now()) > 15 Then
set RS = server.CreateObject ("ADODB.Recordset")
set RS2 = server.CreateObject ("ADODB.Recordset")
'exemplo de query que irá roda:
RS2.Open "SELECT numero from PI_TESTES WHERE ID = 5",conn,1
numero = RS2("numero")
numero = numero + 2
RS.Open "UPDATE PI_TESTES SET numero = '"&numero&"' "+_
"WHERE ID = '5' ",conn,1
Application("LastRun") = Now()
End If
End Sub
</SCRIPT>
If anyone has any other solution, I am also willing to adopt.