Article delegate-en/4731 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
[Reference:<_A4727@delegate-en.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Re: changing name of stdout.log
20 Jan 2010 08:48:03 GMT Stefan Demmig <poqjabdyi-xtqvdm5mnljr.ml@ml.delegate.org>


Dear Yutaka,

since you are not sure, that the CRON mechanism works with Windows, I wrote a litte VB script, which should do the job. I let it run every night. It deletes old files and empty folders:

------------------------------------------------------------
rem Script zum Löschen von alten Cache-Dateien, Aufruf-Parameter 1: Cache-Verzeichnis, Aufruf-Parameter 2: Mindestalter in Tagen
rem poqjabdyi-xtqvdm5mnljr.ml@ml.delegate.org
option explicit

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim WshShell, WshNetwork, fso, fld, fil, version
Dim DelegateCachePath, DateToDelete, DeleteDate

Set WshShell = CreateObject( "WScript.Shell" )
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")

DelegateCachePath = WScript.Arguments.Item(0)
set fld = fso.GetFolder(DelegateCachePath)
DateToDelete = Now - WScript.Arguments.Item(1)
DeleteDate = Year(DateToDelete) & right("0" & Month(DateToDelete),2) & right("0" & Day(DateToDelete),2)

Wscript.Echo "VB-Script """ & WScript.ScriptFullName & """"
set fil = fso.GetFile(WScript.ScriptFullName)
version = Year(fil.DateLastModified) & right("0" & Month(fil.DateLastModified),2) & right("0" & Day(fil.DateLastModified),2) & "_" & right("0" & Hour(fil.DateLastModified),2) & right("0" & Minute(fil.DateLastModified),2)
Wscript.Echo "Version " & version
Wscript.Echo "Bereinige CacheVerzeichnis """ & DelegateCachePath&""""
Wscript.Echo "Loesche alle Daten vor dem " & right("0" & Day(DateToDelete),2) & "." & right("0" & Month(DateToDelete),2) & "." & Year(DateToDelete)

DeleteDirectoryTree fld

Sub DeleteDirectoryTree(ByVal Folder)
	Dim File, SubFolder, ModifiedDate
	
	for each File in Folder.Files
		ModifiedDate=Year(File.DateLastModified) & right("0" & Month(File.DateLastModified),2) & right("0" & Day(File.DateLastModified),2)
		if ModifiedDate<DeleteDate then
			Wscript.Echo "      loesche Datei """ & File.Path & """, " & File.DateLastModified
			fso.DeleteFile(File.Path)
		end if
	Next
	for each SubFolder in Folder.SubFolders
		DeleteDirectoryTree SubFolder
	Next
	if Folder.Files.Count + Folder.SubFolders.Count = 0 then
		Wscript.Echo "      entferne Verzeichnis """ & Folder.Path & """"
		fso.DeleteFolder(Folder.Path)
	end if
end Sub
----------------------------------------------------------------

It can be started by:
cscript "<filename>.vbs" "<Delegate Cache Path>" <min. age of files to be deleted in days>

so cscript "c:\windows\batchfiles\PurgeDelegateCache.vbs" "f:\DelegateCache" 10
means use script "c:\windows\batchfiles\PurgeDelegateCache.vbs" (the above) to purge folder"f:\DelegateCache" deleting files which were last changedmore than 10 days ago.

If you find it useful, feel free to use and distribute it.

By the way, why are there so many empty folders in the cache? They seem not to be of any use. May they be deleted overnight or should they remain?

Best regards

Stefan Demmig
Systembetreuer Windows

Universität Augsburg
Zentralverwaltung, Referat IV/4
Universitätstr. 2
D-86159 Augsburg

Präsidiumsgebäude, Zimmer 3072

phone: +49 000 000 000f
fax: +49 000 000 000f
email: poqjabdyi-xtqvdm5mnljr.ml@ml.delegate.org
ICQ: 355004633
Skype: stefan-demmig

Am 14.01.2010 13:59, schrieb Yutaka Sato:
> Hi Stefan,
>
> In message<_A4726@delegate-en.ML_>  on 01/14/10(19:25:34)
> you Stefan Demmig<poqjabdyi-xtqvdm5mnljr.ml@ml.delegate.org>  wrote:
>   |I have got another point to discuss. I wonder if I completely understud the EXPIRE process. in my parameter list
> ...
>   |arg[3] SERVER=http
> ...
>   |arg[10] EXPIRE=1d:*:*:*
>   |arg[11] CRON=30 0 * * 1-5 -expire 30d
> ...
>   |I wanted the system to expire files after 1 day and to delete expired files
>   |after 30 days so that after 31 days of no trafic the cache would be empty again.
>   |Is the parameter pair 10 + 11 correct and will it work under Windows?
>
> Sorry but I've not tested "CRON ... -expire" enough especially
> on Windows.
>
>   |What happens, if a file on a web server changes before 1 day. Will I receive the
>   |cached file or will it be reloaded from the original server, since it changed?
>
> The EXPIRE=xxx parameter makes DeleGate reuse cached data anyway
> while the age of a cahced data is newer than xxx, by default.
> But clients (browsers) can override this behavior by indicating
> forced "reload" or "veriry" a cached data as supported (with Pragma
> or Cache-Control header in the HTTP protocol).
> In a typical implementation of a browser, reloading will cause
> verifiation of freshness, and if it modified after the time of
> the cache, the latest version will be downloaded (and cached).
>
>   |If I normally receive the cached version of the file, I should keep the cache
>   |period as small as possible. There might exist a mechanism which checks if the
>   |cached file is still up to date (some time&date data from the original server)
>   |and if not so reloads the file. The cached file will be removed if not accessed
>   |by any client for a certain period of time e.g. 1 month.
>
> Cheers,
> Yutaka
> --
>    9 9   Yutaka Sato<y.sato@delegate.org>  http://delegate.org/y.sato/
>   ( ~ )  National Institute of Advanced Industrial Science and Technology
> _<    >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan
> Do the more with the less -- B. Fuller

  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V