Solved

Automatically delete files based on last accessed time

Posted on 2011-03-01
5
840 Views
Last Modified: 2012-05-11
I'm looking for a way to automatically delete files from our SAN based on last accessed time. SAN vendor doesn't have a method to do this but suggested a program called Delete Files by Date Software. I attempted to test this software but they don't offer any trial period, you can download and view files but in order to test it's functionality you must purchase a license, so while I was uninstalling that waste of time I decided to ask the experts.
I had also tried a program called Delenda, which seems to do what I want but doesn't seem to work. I pointed it at a directory (12k files, 3.5GB) and let it run for 24 hours with no progress.
So what I need is a decent program that can run automatically (as a service preferably) that can delete files based on their last accessed time.

Any suggestions?
0
Comment
Question by:js479
  • 2
  • 2
5 Comments
 
LVL 77

Accepted Solution

by:
arnold earned 250 total points
ID: 35011389
To what server is the LUN allocated?
There is a fairly simple perl script that can run through using stat("$filename")[8] will have the atime for the file. Note that if you mount the LUN with noatime option, the atime will not be current/valid.

It will make matters simpler if there is a specific location where you want to check for files.

A similar mechanism can be setup with a Vbscript/C# using fileobject.
You did not specify the platform your server is on and the use of service suggests a windows based platform.
Out of caution, you migh want to consider an intermediary storage location. I.e. move the files to another directory and then after another period of time delete those files from the other directory.

Might Scheduled task also be an option?
0
 
LVL 5

Assisted Solution

by:group0
group0 earned 250 total points
ID: 35015291
If you're running a *nix-based OS and are trying to recursively delete all files from a starting directory that haven't been accessed in at least n days, this can be easily done with find (the syntax varies between the different flavors):

To see the list of affected files (to verify the affected file list is correct)

find /path-to-start-in -atime +n


To delete the affected files:

find /path-to-start-in -atime +n -exec rm -f {} \;


The {} signifies the filename found, so the exec command can easily be changed to just move the file to a temporary location as suggested earlier:

find /path-to-start-in -atime +n -exec mv -f {} /tmp \;


This may work even on a Windows platform, if you have cygwin or its equivalent installed
0
 
LVL 5

Expert Comment

by:group0
ID: 35015305
As I said, the syntax varies between the different platforms, the examples I provided above are for Linux under CentOS.  Make sure to consult the man pages to be sure if you use this.
0
 
LVL 1

Author Comment

by:js479
ID: 35017503
My apologies for not being more specific in the original question.

The SAN is creating CIFS shares that we can connect to via our windows machines. So the SAN is called DC-BA-01 and I create a CIFS share called Work, I can then access and map that CIFS share from any of my windows servers using \\DC-BA-01\work. All of our servers are either windows 2003 or 2008.


0
 
LVL 77

Expert Comment

by:arnold
ID: 35019896
The san is then running a linux based os with samba shares.
Do you have an option to run jobs on the SAN?
If you are a windows shop, you would use vbscript and fileobject to traverse the directoreis looking at each files atime.

There are many examples of using VBscript to list files in directories, etc. that you can use and incorporate into a script that you need to run as a scheduled task to delete these files.
A simple search for "vbscript list files in directory" will provide several examples.
Using the vbscript guide for fileobject access will provide info on how to use it to access the access time, modify time, create time of the file and then compare and perform action on the file as you see fit.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Free Text Editor for Large files? 11 67
Tablet PCs slow responsiveness relative to other local non-tablet PCs. 10 89
Determining Project Cost 1 74
SQL Server memory Issue 7 119
A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
The viewer will learn common shortcuts with easy ways to remember them. The viewer will then learn where to find all of the keyboard shortcuts, how to create/change them, and how to speed up their workflow.

776 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