Because the site needs frequent updates to the home page, sometimes using a CDN often leads to the home page is generating content when synchronizing data (may be conflict, often lead to the home page is empty), This is the thought of Mr. As a not the first page of the index2.htm and then copied again for the index.htm, so that index2 frequent reading and writing is no problem. So the first to Judge Index2.htm is not empty time to copy, and must be newer than index.htm to copy. This will require some scripting support.
A few days ago wrote a (bat+xcopy to achieve only copy than the target file updates) or appear as empty situation, here Special add some functions, refer to many web site articles, thanks to the results of Baidu is very powerful.
Let's start with a bat version.
Copy Code code as follows:
@echo off
:: Copy the following page every 5 minutes
for/f%%i in (' dir/b c:\index2.htm ') do (
Set Indexdx=%%~zi
)
If%indexdx% GTR 5120 (
echo y | xcopy C:\index2.htm/d/r/k c:\index.htm
)
where for/f%%i in (the ' dir/b c:\index2.htm ') do (
Set Indexdx=%%~zi
)
Gets the size of the index2.htm file in bat.
Then through the If%indexdx% gtr 5120 (
Implementation judgment is not greater than 5,120 bytes
The main thing is the following code is more powerful, but also relatively simple
Copy Code code as follows:
Dim FSO
Set fso = CreateObject ("Scripting.FileSystemObject")
Set FN2=FSO. GetFile ("c:\index2.htm")
Flsize2=fn2.size
Fldate2=fn2.datelastmodified
Set FN=FSO. GetFile ("c:\index.htm")
Flsize1=fn.size
Fldate1=fn.datelastmodified
If FSO. FileExists ("c:\index2.htm") and flsize2>50000 and Fldate2>fldate1 Then
Fso.getfile ("c:\index2.htm"). Copy ("C:\index.htm")
If Err.number=0 then WriteHistory "Success" &now (), "Log.txt"
End If
Sub writehistory (hischars, Path)
Const ForReading = 1, ForAppending = 8
Dim FSO, F
Set fso = CreateObject ("Scripting.FileSystemObject")
Set f = fso. OpenTextFile (Path, ForAppending, True)
F.writeline Hischars
F.close
End Sub
There is also the log function, under the current bat can also be. Need to be able to expand on their own.
cloud-dwelling community remote articles, reproduced please indicate the source.