Google Answers Logo
View Question
 
Q: Need a small scheduled task written. ( No Answer,   2 Comments )
Question  
Subject: Need a small scheduled task written.
Category: Computers > Programming
Asked by: warrens-ga
List Price: $30.00
Posted: 05 Jan 2006 03:51 PST
Expires: 05 Jan 2006 18:24 PST
Question ID: 429383
I have a MS Access 2000 database on a shared server hosted by
EasyCGI.com and want to set up a Scheduled Task to rename the database
every day at a certain time and then replace it with an empty database
copy. This is because when Access Databases get large they get
sluggish and use up significant percentages of the shared servers
processing power, and my hosting company doesn't like that.

For example, each day at midnight, I want "site.mdb" renamed with the
day's date such as "site20060105.mdb" and then using an empty copy of
the database that I have placed on the server I want "NEWsite.mdb"
copied as "site.mdb" leaving "NEWsite.mdb" also there so it is
available for the next day, and the next, etc.

My web hosting company said this:  "We do provide a scheduled task
mechanism in your Easy CGI control panel, but it can only execute
browsable scripts."

You don't need to tell me how to set up the scheduled task in their
control panel, but rather it is the browsable script that I need
written.  I thought I could write a .bat file and compile it to an
.exe (using any of a number of tools available for that purpose) but
that didn't work.  Here is the .bat file that does what I want it to
do locally on my machine, but not when it is on their server. (I am
using the word "site" for my website name instead of my actual name
and will substitute my site name myself.)

@echo off
@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( 
   Set Month=%%A
   Set Day=%%B
   Set Year=%%C
)

copy /Y c:/websites/site51/site.com/db/site.mdb
c:/websites/site51/site.com/db/site%Year%%Month%%Day%.mdb

copy /Y c:/websites/site51/site.com/db/NEWsite.mdb
c:/websites/site51/site.com/db/site.mdb

You can get full specs for their shared servers at www.Easycgi.com,
but here are the basics:  Windows 2000, Perl, PHP, and ASP support.  I
know the most about ASP and so would prefer a solution using ASP (if
that is applicable and is a "browseable script," but at this point
whatever works is good enough.

Thanks.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Need a small scheduled task written.
From: ratty_-ga on 05 Jan 2006 10:49 PST
 
Hi

Why not just write it in asp?

For example:

  Dim objFSO
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

  objFSO.MoveFile Server.MapPath("/someDir/current.asp"), _
                  Server.MapPath("/someDir/20060105.asp")

  Set objFSO = Nothing

will rename your existing file. Then you can use standard asp stuff
(eg "now" to get the current date and build up the destination
filename).

In a similar way:

  Set f2 = objFSO.GetFile("c:/websites/site51/site.com/db/NEWsite.mdb")
  f2.Copy("c:/websites/site51/site.com/db/site.mdb")
  Set f2 = nothing

will copy your new file for today.

Then you can call this something like DailyUpdate.asp

Finally you need to get it called once per day. I recommend you set it
at, say 00:05 so that if there is a slight glitch in the running of
it, at least it will always run on the correct day.

Ratty
Subject: Re: Need a small scheduled task written.
From: warrens-ga on 05 Jan 2006 18:22 PST
 
Hi ratty,  thanks for the reply. It took a little doing, but your
reply gave me enough info so that I was able to make things work the
way I want.

So THANK YOU very much for that!

Here's the final script

<%
Dim y
Dim m
Dim d
Dim outputfilename
Dim fso
Dim f2

Response.clear()

y = Year(Date)
m = Month(Date)
if m < 10 Then m = "0" & m
d = Day(Date)
if d < 10 Then d = "0" & d

outputfilename = "\db\site" & y & m & d & ".mdb"

Set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.CopyFile Server.MapPath("\db\site.mdb"),  Server.MapPath(outputfilename)

Set f2 = fso.GetFile("c:/websites/site51/site.com/db/NEWsite.mdb")
f2.Copy("c:/websites/site51/site.com/db/site.mdb")

Set f2 = nothing
Set fso = nothing

Response.write(outputfilename & " created. <br>Maintenence Complete")
%>

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy