Solved

Automatically delete files based on last accessed time

Posted on 2011-03-01
5
843 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
[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
  • 2
5 Comments
 
LVL 78

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 78

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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

707 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