Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Scripting in Cygwin

Posted on 2012-03-13
2
Medium Priority
?
696 Views
Last Modified: 2013-11-15
Hello,

I am in a situation here at work where.

I've been asked to delete some files by date... Easy enough right?

The kicker here is that i have to do so against 20+ million files in a single NAS Dir... Oh yeah, I know! Any way, I do not have a Unix server to work with and the windows API basically excretes a brick when I try any "Windowy" method of doing this (cmd, WMI, bla bla bla). I do however have access to a windows 2003 server running Cygwin which I am trying to utilize against the NAS directory for the clean up effort.

Here's the issue. I have mapped the NAS directory as a drive on the Windows box and am wanting to run a command something like: find . -mtime +186 -exec rm -f {} \; -print but with the right logic in place so as to identify only the right files. As I am no Unix expert I am taking baby steps towards that end.

The NAS dir does have subdirectories which include files that must not be deleted which is ok as the target files are all .log but when I try to run a simple find . -name  "*log"
I get back the below where I am expecting to see many many files. Any help here would be very appreciated. Oh, and I just joined today and have yet to have the time to read up on points and all that so please be forgiving and let me know if i've broken and social rules here in regard to points.
Thank you

$ find . -name  "*log"
./ESUB20081023.log
./ESUB20081024.log
./SubmissionDocSrv20081024.log
./SubmissionDocSrv_20081107.log
./SubmissionDocSrv20081027.log
./SubmissionDocSrv_20081110.log
find: /cygdrive/z/TransformXML changed during execution of find (old inode numbe
r -425971704, new inode number -416921728, filesystem type is system) [ref 1114]

find: /cygdrive/z/TransformXML changed during execution of find (old inode numbe
r -425971704, new inode number -431260960, filesystem type is system) [ref 1114]
0
Comment
Question by:UserAlreadyExists
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Assisted Solution

by:serialband
serialband earned 1000 total points
ID: 37715953
The error messages show that the is changing.

http://www.gnu.org/software/findutils/manual/html_node/find_html/Error-Messages-From-find.html

What do you mean by "the windows API basically excretes a brick when I try any "Windowy" method of doing this"?  Did forfiles.exe not work for you?
0
 
LVL 10

Accepted Solution

by:
pfrancois earned 1000 total points
ID: 37719866
The syntax of the find command executed in the directory where you want to delete the older .log files will be something like:

find *.log -prune -mtime +186 -exec rm -f {} \; -print 

Open in new window


*.log will list all the files ending with .log
-prune will prevent to descend into sub-directories
-mtime +186 will restrict the matching to files that are not modified in the last 6 monthes
-exec rm -f {} \; will remove these files
-print will echo the name of the processed file on the output

I don't think you will have the error message above, since the modified file is not ending in .log.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question