Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

removing .tmp files older than 1 hour

1,955 views
Skip to first unread message

daniel...@gmail.com

unread,
Nov 19, 2013, 6:54:48 AM11/19/13
to
Under a directory (C:\WebSphere\AppServer\profiles\.....\ClinicalReportServerEAR-PROD.ear\), I have a ton of .tmp files filling up C:/ drive as .tmp files are being generated every minute or so.

I need to purge .tmp files permanently if they are older than 1 hour.

Please let me know DOS command lines to purge .tmp files if .tmp files are older than 1 hour.

I plan to use .bat (with MS-DOS) and put it under 'Task Scheduler'.

My server is:

OS Name: Microsoftr Windows Serverr 2008 Enterprise
OS Version: 6.0.6002 Service Pack 2 Build 6002

Appreciate your help!



foxidrive

unread,
Nov 19, 2013, 7:18:29 AM11/19/13
to
On 19/11/2013 22:54, daniel...@gmail.com wrote:
> Under a directory (C:\WebSphere\AppServer\profiles\.....\ClinicalReportServerEAR-PROD.ear\), I have a ton of .tmp files filling up C:/ drive as .tmp files are being generated every minute or so.
>
> I need to purge .tmp files permanently if they are older than 1 hour.

Instead of checking for file age, this will delete all *.tmp files except for the most recent 100 *.tmp
files.


@echo off
set "folder=C:\WebSphere\AppServer\profiles\.....\ClinicalReportServerEAR-PROD.ear"
for /f "skip=100 delims=" %%a in ('dir "%folder%\*.tmp" /b /a-d /o-d ') do del "%folder%\%%a"


> Please let me know DOS command lines to purge .tmp files if .tmp files are older than 1 hour.
>
> I plan to use .bat (with MS-DOS) and put it under 'Task Scheduler'.
>
> My server is:
>
> OS Name: Microsoftr Windows Serverr 2008 Enterprise
> OS Version: 6.0.6002 Service Pack 2 Build 6002

Maybe that will do for your application.

daniel...@gmail.com

unread,
Nov 19, 2013, 8:26:22 AM11/19/13
to
foxidrive,

Thank you for your reply.
I tried on cmd prompt.

C:\>@echo off
set "folder=C:\WebSphere\AppServer\profiles\Dmgr\config\temp\download\cells\MCHO
DR01Cell01\applications\ClinicalReportServerEAR-PROD.ear\"
for /f "skip=100 delims=" %%a in ('dir "%folder%\ClinicalReportServerEAR-PROD*.t
mp" /b /a-d /o-d ') do del "%folder%\%%a"
%%a was unexpected at this time.

I am not sure "%%a was unexpected at this time" means...
Please advise.

foxidrive

unread,
Nov 19, 2013, 9:27:47 AM11/19/13
to
On 20/11/2013 00:26, daniel...@gmail.com wrote:
> Thank you for your reply.
> I tried on cmd prompt.
>
> I am not sure "%%a was unexpected at this time" means...
> Please advise.

cmd prompt uses %a and batch file uses %%a - try it in a batch file.



daniel...@gmail.com

unread,
Nov 19, 2013, 9:34:37 AM11/19/13
to
On Tuesday, November 19, 2013 9:27:47 AM UTC-5, foxidrive wrote:
>
>
> > Thank you for your reply.
>
> > I tried on cmd prompt.
>
> >
>
> > I am not sure "%%a was unexpected at this time" means...
>
> > Please advise.
>
>
>
> cmd prompt uses %a and batch file uses %%a - try it in a batch file.

Thank you, foxidrive.

I tried with %%a in .bat file. I ran it, but nothing got removed..
Please advise.
Message has been deleted
Message has been deleted

big_jon...@lycos.co.uk

unread,
Nov 19, 2013, 2:26:01 PM11/19/13
to
Since you're on 2k8 I see no reason why you wouldn't run this single line of powershell code from a .ps1 file in your "C:\WebSphere\AppServer\profiles\.....\ClinicalReportServerEAR-PROD.ear" directory as a scheduled task!

gci .\*.tmp | where-object {$_.LastWriteTime -lt [DateTime]::Now.AddHours(-1)} | ri

daniel...@gmail.com

unread,
Nov 19, 2013, 9:20:27 PM11/19/13
to
Would this be the syntax? I tried it, but not working.. Please advise.

@echo off
set "folder=C:\WebSphere\AppServer\profiles\Dmgr\config\temp\download\cells\MCHODR01Cell01\applications\ClinicalReportServerEAR-PROD.ear\"
gci .\ClinicalReportServerEAR-PROD*.tmp | where-object {$_.LastWriteTime -lt [DateTime]::Now.AddHours(-1)} | ri

foxidrive

unread,
Nov 19, 2013, 11:36:34 PM11/19/13
to
Did you put the correct path in? Were there more than 100 *.tmp files?
Were there any message on the console?

daniel...@gmail.com

unread,
Nov 20, 2013, 1:05:18 AM11/20/13
to
yes, the path is correct.

daniel...@gmail.com

unread,
Nov 20, 2013, 1:05:47 AM11/20/13
to
an no messages on the console.

foxidrive

unread,
Nov 20, 2013, 3:08:31 AM11/20/13
to
On 20/11/2013 17:05, daniel...@gmail.com wrote:

>> > Did you put the correct path in? Were there more than 100 *.tmp files?
>> >
>> > Were there any message on the console?

> an no messages on the console.

As it was presented it would only delete old *.tmp files if there were more than 100 *.tmp files.

You can change the skip=100 to 20 or less if you think that would be ok in your situation.



big_jon...@lycos.co.uk

unread,
Nov 20, 2013, 11:52:26 AM11/20/13
to
I gave you the exact code you needed and told you what do do with it, however if you are not wanting to keep the script in the directory in question then something like this is what you want. There are four lines only, do not add anything else.

$SrceFldr = "C:\WebSphere\AppServer\profiles\Dmgr\config\temp\download\cells\MCHODR01Cell01\applications\ClinicalReportServerEAR-PROD.ear"
$FrntName = "ClinicalReportServerEAR-PROD"
$1HourOld = [DateTime]::Now.AddHours(-1)
Get-ChildItem "$SrceFldr\$FrntName*.tmp" | where-object {$_.LastWriteTime -lt $1HourOld} | Remove-Item

Depending upon your source files it may be preferable to change 'LastWrite' to 'Creation'
0 new messages