Has time passed?

They have: 133 posts

Joined: Sep 2000

I am looking for a way to execute a couple of lines of code one time a day; when a surtain time has passed.

I would have it to execute the function
exec1()
at 12 AM
and
exec2()
at 12 PM.

I know that I would need to be able to get some kind of SQL scheduler, which I probably can't. Therefore I believe that the best way to do it, is to check if the time has passed, and if so it will be executed.
I would save when it was executed the last time in a textfile, where the information is in.

However I do not see how I could check it anyway.

So, can someone help me with this?
I used to do it one time a day, when the date has changed, but as I see it now that is imposibly, since I need to make it happen twice a day.

I really hope someone can help me, since I am starting to grow our gray hairs of trying to figure this out!

Thank you very much in advance.

~Casper Bang

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

hi hotcut,

what lanuage are you using?
it may be possible to do a loop that repeats after a time difference (12hrs). Smiling ie: it does a certain action again and again every 12hrs, but for which (probably) you will need to have the program constantly running. Sad

i can be of better assistance if you post what language you are using...and if u have access to the server administration where you are hosting the program.

otherwise, as you said the only other alternative would be to get a scheduler. Laughing out loud

They have: 133 posts

Joined: Sep 2000

I am using VBscript, however I am starting to feel I might have figured out how to do it...
I will come back here later, when I know if I can do it!

Thanks
~casper

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

There's a few ways to dot his:

1) Schedule it to run as a .vbs file under Windows scheduler (need access to server).

2) Schedule it to run as a SQL Job (Need admin access to SQL)

3) Schedule it to run on your computer (calls asp file on the server)

4) If it's a busy site you could use an application variable. And everytime a session begins or ends you can check the time.

PJ | Are we there yet?
pjboettcher.com

They have: 133 posts

Joined: Sep 2000

Haven't gotten access to the half of this stuff...

However, I managed to do it on my own!

Here is how I did it (for those how cares):

<!-- #include file="game_reset.asp" -->
<%
if CDate(lastresetdate) < CDate(date()) then
'perform reset for first half of the map


'performing reset


'updatinbg reset-file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(server.mappath("game_reset.asp"), 2, True)
var1 = "%"
var2 = ">"
objFile.write "<%lastresetdate = """&date()&""""&VbCrLf&"lastresettime = """&now()&""""&VbCrLf&"newresettime = """&DateAdd("h", 12, now())&""""&var1&var2
objFile.Close
Set objFSO = Nothing
end if


if CDate(lastresettime) < CDate(newresettime) then
'if the AM reset haven't been processed
if CDate(now()) > CDate(newresettime) then
'perform reset forthe second half of the map

'performing reset

'updating reset-file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(server.mappath("game_reset.asp"), 2, True)
var1 = "%"
var2 = ">"
objFile.write "<%lastresetdate = """&date()&""""&VbCrLf&"lastresettime = """&now()&""""&VbCrLf&"newresettime = """&now()&""""&var1&var2
objFile.Close
Set objFSO = Nothing
end if

end if



'end reset
'

Thank you very ´much for the help anyway.

~Casper

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.