Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to create a SCHEDULED TASK that will kick off a FORFILE loop, and terminate the process after an hour (or 12 hours). I expect there to be MILLIONS of files the the paths defined, and I want to run the task off-hours to minimize the performance impact.

The code I'm trying to run is:

forfiles /P "E:\Mutex_01" /S /M *.txt /D -5 /C "cmd /c del @path"

Looking in the logs, I don't get the sense that task is running correctly. When I enumerate the folder, there is no change. Am I missing something? How can I become the expected result?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Personally I would do it differently... I would kick off the routine interactively and then schedule a script that has:

PSKILL forfiles.exe
PSKILL CMD.EXE

Schedule that script to run at a particular time with administrative credentials.

You could even do a test right now... start the forfiles routine, and schedule your kill script to run five minutes from now...

share|improve this answer
1  
This worked! Not allowed to use PSKill (even though it is a Sysinternals product), but was able to use it with TASKKILL. Thanks! –  Jerry Sweeton Apr 8 '13 at 21:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.