I automatically restart the SpamD service daily (3.2.3.5 run using srvany.exe), I have noticed that temp files are left in the Windows\Temp Directory. I've just noticed this as it was causing other Perl services to hang, there was 2GB of data orphaned!
A Folder (e.g. pdk-SYSTEM-2116)usually containing 3mb of dll temp files is left along with various .spamassassin-4008OacRUTtmp files. In the first instance SYSTEM refers to the User and 2116 refers to the process in memory (SpamD).
Is there any way of cleaning up these items upon destruction of the SpamD instance?
Kind regards
mediademon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes, i noticed this too. After awhile it tends to add up especially if this is run on a mailserver. I would be interested in knowing how to go about deleting these temp files too
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
REM Get Date
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set date=%%l%%k%%j%%i
FOR /F "tokens=1-9 delims=:. " %%i in ('time/t') do set time=%%i%%j%%k%%l
REM Create Log Filename
set FILENAME=spamd
set LOGNAME=%filename%_%date%%time%.log
net stop spamassassin
C:
cd \progra~1\spamassassin\logs
REM Convert from UNIX text
TYPE spamd.log | FIND "" /V > %logname%
DEL spamd.log
REM Remove Temp Files
cd \Batch
call rmtree.bat C:\Windows\Temp\pdk-SYSTEM-*
del c:\Windows\Temp\.spamassassin*.*
net start spamassassin
----------------
You will of course have to change the service name and file locations to suit your install and maybe you need a different date format too (currently yyyymmddtttt so it sorts ok), but it's a good starting point!
Hi,
I like to pick up this thread again.
@Eugene
Is there any way to tell spamd.exe to quit softly instead of killing the process which means those PDK temp files remain?
Greetings,
Harry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I asked the support guys from Active-State if there is any way to stop/restart a perlApp exe like spamd.exe without having those temp files left.
Here is what I got:
----------
Harald,
In your situation, there is not much you can do. If this was a PerlSvc, and not a PerlApp, you could send a graceful stop to the service. If it is a PerlApp, the only thing you can do is talk to the supplier of the executable.
There are compile-time options which could stop this behavior, such as not using --clean (to force it to reuse the same files), or dynamically linking instead of relying on tempfiles.
Let me know if you have any further questions or comments.
Best regards,
Graham Stuart
Technical Support Engineer
ActiveState - Dynamic Tools for Dynamic Languages http://www.ActiveState.com
Harald Binkle <binkle@jam-software.de> wrote:
> Hello Graham,
> thank you for the fast reply.
> The problem is that I not only get that Perl application "as is". I do
> get a whole exe file created with perlapp.
> I use that exe together with my own perlapp exe files. So I's really
> hard to create a wrapper.
>
> I don't care about the temp files when that exe crashes. The main
> problem is that I need to restart that exe (process) nearly every hour.
> So I'm simply searching for a way to tell the exe to quit without
> leaving the temp files.
>
> Best regards,
>
> Harald Binkle
>
> > -----Original Message-----
> > From: ActiveState Support [mailto:support@activestate.com]
> > Sent: Friday, December 28, 2007 6:31 PM
> > To: Harald Binkle
> > Subject: Re: [OTS#020091337] kill process created with perlapp
> >
> > Harald,
> >
> > May I make an alternative suggestion? I ran into similar problems to
> > this in a former life as a sysadmin. Running a clean-up on exit is
> > not dependable, since you can't guarantee that the process will
> > always be shut down in an orderly fashion. Since there might be
> > files from an uncontrolled crash, you have to write the code to find
> > and delete all expired temporary files. In the event of a general
> > shutdown, this can also interact with other system activities in an
> > adverse manner. Modern file systems are a lot more resilient than
> > they used to be, but it's still probably better to avoid forcing the
> > system to deal with an uncertain state.
> >
> > I suggest that you write a wrapper for the "as-is" application, and
> > then compile the wrapper. Have the wrapper do a complete clean-up
> > before it calls the main application. That way you will always know
> > the temporary files are not in use, and the chance of a timing
> > problem is much lower. You will have to be careful to pass the
> > correct environment variables along, but I found this approach was
> > more consistent and let me change the apparent behavior of code I
> > could not modify.
> >
> > If there is some reason which forces the clean on exit strategy, let
> > me know, and I'll pass it along to our developers for suggestions.
> >
> > Best regards,
> >
> > Graham Stuart
> > Technical Support Engineer
> > ActiveState - Dynamic Tools for Dynamic Languages
> > http://www.ActiveState.com
> >
> > Harald Binkle <binkle@jam-software.de> wrote:
> >
> > > Hello,
> > > I have several exe files created with perlapp. One of these I need
> > > to
> > take "as
> > > is". When I start it, it remains in memory until I kill the process.
> > > Now my problem is, that after killing the process all temporary
> > > files
> > created
> > > for the perl-runtime remain in the temp folder. (e.g.
> > > C:\WINDOWS\system32\config\systemprofile\Lokale
> > > Einstellungen\Temp\pdk-SYSTEM-2668)
> > > So after some time there are hundreds of these folders where each
> > > has
> > about
> > > 3MB of files.
> > >
> > > Is there any way to quit a file created with perlApp softly so
> > > that
> > it removes
> > > its temp files?
> > > I tried to send WM_Quit but with no success.
> > >
> > > Best regards,
> > >
> > > Harald Binkle
----------
So the only way seems to be Eugene needs to do some changes.
@Eugene - would you do that?
Greetings
Harry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I automatically restart the SpamD service daily (3.2.3.5 run using srvany.exe), I have noticed that temp files are left in the Windows\Temp Directory. I've just noticed this as it was causing other Perl services to hang, there was 2GB of data orphaned!
A Folder (e.g. pdk-SYSTEM-2116)usually containing 3mb of dll temp files is left along with various .spamassassin-4008OacRUTtmp files. In the first instance SYSTEM refers to the User and 2116 refers to the process in memory (SpamD).
Is there any way of cleaning up these items upon destruction of the SpamD instance?
Kind regards
mediademon
yes, i noticed this too. After awhile it tends to add up especially if this is run on a mailserver. I would be interested in knowing how to go about deleting these temp files too
Hi
Thought I would share my batch files for this until it's cleaned up in the application.
First you need a batch file to recursively delete directories using wildcards (use with caution!), i've called it rmtree.bat.
----------
rmtree.bat
----------
@echo off
REM Remove Directories Recursively Using Wildcards
if "%~1"=="" echo Please supply directory name&goto :EOF
for /f "delims=" %%a in ('dir "%~1" /s /b /ad 2^>NUL') do rd /s /q "%%a"
:EOF
---------
Now the main file which rotates the logs and cleans up!
----------------
spamassassin.bat
----------------
@echo off
REM Restart SpamAssassin Service
REM Get Date
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set date=%%l%%k%%j%%i
FOR /F "tokens=1-9 delims=:. " %%i in ('time/t') do set time=%%i%%j%%k%%l
REM Create Log Filename
set FILENAME=spamd
set LOGNAME=%filename%_%date%%time%.log
net stop spamassassin
C:
cd \progra~1\spamassassin\logs
REM Convert from UNIX text
TYPE spamd.log | FIND "" /V > %logname%
DEL spamd.log
REM Remove Temp Files
cd \Batch
call rmtree.bat C:\Windows\Temp\pdk-SYSTEM-*
del c:\Windows\Temp\.spamassassin*.*
net start spamassassin
----------------
You will of course have to change the service name and file locations to suit your install and maybe you need a different date format too (currently yyyymmddtttt so it sorts ok), but it's a good starting point!
Hope this helps
mediademon
http://www.mediademon.com
Why don't you just use:
cd \windows\temp
rmdir . /s /q
This one deletes all files and directories in \windows\temp, exept those which are in use by another process.
It also leaves the \windows\temp directory intact, since you are sitting on that directory by yourself.
Hi,
I like to pick up this thread again.
@Eugene
Is there any way to tell spamd.exe to quit softly instead of killing the process which means those PDK temp files remain?
Greetings,
Harry
Hi,
I asked the support guys from Active-State if there is any way to stop/restart a perlApp exe like spamd.exe without having those temp files left.
Here is what I got:
----------
Harald,
In your situation, there is not much you can do. If this was a PerlSvc, and not a PerlApp, you could send a graceful stop to the service. If it is a PerlApp, the only thing you can do is talk to the supplier of the executable.
There are compile-time options which could stop this behavior, such as not using --clean (to force it to reuse the same files), or dynamically linking instead of relying on tempfiles.
Let me know if you have any further questions or comments.
Best regards,
Graham Stuart
Technical Support Engineer
ActiveState - Dynamic Tools for Dynamic Languages http://www.ActiveState.com
Harald Binkle <binkle@jam-software.de> wrote:
> Hello Graham,
> thank you for the fast reply.
> The problem is that I not only get that Perl application "as is". I do
> get a whole exe file created with perlapp.
> I use that exe together with my own perlapp exe files. So I's really
> hard to create a wrapper.
>
> I don't care about the temp files when that exe crashes. The main
> problem is that I need to restart that exe (process) nearly every hour.
> So I'm simply searching for a way to tell the exe to quit without
> leaving the temp files.
>
> Best regards,
>
> Harald Binkle
>
> > -----Original Message-----
> > From: ActiveState Support [mailto:support@activestate.com]
> > Sent: Friday, December 28, 2007 6:31 PM
> > To: Harald Binkle
> > Subject: Re: [OTS#020091337] kill process created with perlapp
> >
> > Harald,
> >
> > May I make an alternative suggestion? I ran into similar problems to
> > this in a former life as a sysadmin. Running a clean-up on exit is
> > not dependable, since you can't guarantee that the process will
> > always be shut down in an orderly fashion. Since there might be
> > files from an uncontrolled crash, you have to write the code to find
> > and delete all expired temporary files. In the event of a general
> > shutdown, this can also interact with other system activities in an
> > adverse manner. Modern file systems are a lot more resilient than
> > they used to be, but it's still probably better to avoid forcing the
> > system to deal with an uncertain state.
> >
> > I suggest that you write a wrapper for the "as-is" application, and
> > then compile the wrapper. Have the wrapper do a complete clean-up
> > before it calls the main application. That way you will always know
> > the temporary files are not in use, and the chance of a timing
> > problem is much lower. You will have to be careful to pass the
> > correct environment variables along, but I found this approach was
> > more consistent and let me change the apparent behavior of code I
> > could not modify.
> >
> > If there is some reason which forces the clean on exit strategy, let
> > me know, and I'll pass it along to our developers for suggestions.
> >
> > Best regards,
> >
> > Graham Stuart
> > Technical Support Engineer
> > ActiveState - Dynamic Tools for Dynamic Languages
> > http://www.ActiveState.com
> >
> > Harald Binkle <binkle@jam-software.de> wrote:
> >
> > > Hello,
> > > I have several exe files created with perlapp. One of these I need
> > > to
> > take "as
> > > is". When I start it, it remains in memory until I kill the process.
> > > Now my problem is, that after killing the process all temporary
> > > files
> > created
> > > for the perl-runtime remain in the temp folder. (e.g.
> > > C:\WINDOWS\system32\config\systemprofile\Lokale
> > > Einstellungen\Temp\pdk-SYSTEM-2668)
> > > So after some time there are hundreds of these folders where each
> > > has
> > about
> > > 3MB of files.
> > >
> > > Is there any way to quit a file created with perlApp softly so
> > > that
> > it removes
> > > its temp files?
> > > I tried to send WM_Quit but with no success.
> > >
> > > Best regards,
> > >
> > > Harald Binkle
----------
So the only way seems to be Eugene needs to do some changes.
@Eugene - would you do that?
Greetings
Harry
From changelog of newly released Spamassassin 3.2.4:
------------------------------------------------------------------------
r604715 | jm | 2007-12-16 21:33:52 +0000 (Sun, 16 Dec 2007) | 1 line
bug 5557: some temporary files are left not cleaned up on Windows; fix
------------------------------------------------------------------------
Could it be this?
Hi,
no. I'm using V3.2.5 and they are still there.
Where did you get this bug entry from?
I think latest version of SAWin32 is 3.2.3.5. Bugfix was copied from Spamassassin changelog of version 3.2.4. See www.spamassassin.org.
How is the \windows\temp path derived?
Is it from the TEMP, TMP or TMPDIR environment variable, or something else?