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 using gnuwin32 on Windows Server 2003 SP2. I've written a find command to find all xml files in a certain directory that are older than 20 minutes, and delete them. Here's the command:

C:\gnuwin32\GetGnuWin32\gnuwin32\bin\find.exe /mydir/*.xml -mmin +20 -exec rm -f {} \ ;

This is working fine on 2 of my 3 servers. On the third server, I am getting this error over and over (likely on every file in the directory):

C:\gnuwin32\GetGnuWin32\gnuwin32\bin\find.exe: rm: Invalid argument
C:\gnuwin32\GetGnuWin32\gnuwin32\bin\find.exe: error waiting for rm: No child processes

To troubleshoot, I made sure the find command on its own (without the -exec) was working, which it was, and then I also tried running rm -f on one of the resulting files in the find, and that worked as well.

FYI the reason I am calling the full path on find.exe is because the default "find" command points to the dos "find" command, and I don't want to mess with the PATH to fix this.

share|improve this question
    
replace -exec rm... with -exec echo rm... See what arguments get sent? –  Zoredache Aug 25 '11 at 21:55
    
Just a guess in the dark: rm is not what you think it is. Like the find invariance. What does rm --help say? –  mailq Aug 25 '11 at 21:56
    
@mailq which rm returns C:\gnuwin32\GetGnuWin32\gnuwin32\bin\rm.EXE. @Zoredache, if I include the echo as you suggest, I get the same error as in my original post, but now the error is happening on the echo instead of the rm. –  Jamie Forrest Aug 25 '11 at 22:06
1  
I know that this is only a workaround, but in the meantime you could replace -exec rm ... by just -delete. –  mailq Aug 25 '11 at 22:13
    
Thanks @mailq. I'm using the workaround for now. –  Jamie Forrest Aug 25 '11 at 22:48
show 2 more comments

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.