7

I've got this idea for some time and I was wondering if anyone has seen such a feature/app in any operating system and if you haven't, what do you think about it. Where do you think I should begin?

The idea is simple. I think we all have those files that are made and probably used for a few days and then are left on our disk and we never delete them or even check to see if we need them again. It'd be cool if you could right click on a file and click on "Expire in.. 3 days" for example. And the file gets deleted after 3 days. I have a great need for this and maybe some people will find it useful.

I was thinking of writing a script and use the Nautilus Action project in GNOME for a start.

5
  • 2
    Sounds like a good idea. In production environments with many such files, a separate folder could be designated and a CRON job is run to clean them all every x hours/days/etc. But your idea for individual expiry dates is interesting.
    – NoChance
    May 23, 2012 at 13:08
  • 2
    Has anybody ideas how to manage security permissions for this great idea? sould a hacker be abel to automatically "unistall" a virusscanner after 3 days? or am i able to to delete the personal emails of somebody else?
    – k3b
    May 23, 2012 at 13:31
  • Good points k3b. But I think if it gets properly implemented it would probably be as safe as any normal file deletion activity. So if a hacker can delete a file then he can delete it after 2 days.
    – Auxiliary
    May 23, 2012 at 13:34
  • A more definite statement of your question would help. I've tried to answer your "Where do you think I should begin?" below, but beyond that it's hard to know what you're really asking here.
    – Caleb
    May 23, 2012 at 20:12
  • Plan for a companion audit log since this has a non intuitive destructive consequence.
    – JustinC
    Dec 18, 2012 at 12:00

7 Answers 7

4

Where do you think I should begin?

Begin by writing down a set of use cases that describe all the different ways you can envision for people to use file expiration. Also write down the risks (automatic destruction of evidence, security concerns, etc.).

Next, figure out how the feature should work. How will you keep track of the file expiration date? Is there any way to get an expired file back, or will it really be deleted? Would it be better to have the file system simply hide expired files and only delete them when the space is needed? Developing a detailed understanding of the feature's behavior now will save you a lot of time and effort later.

The next step is to design the feature. Creating some sort of design document will help you stay on track and remember what you're doing even when life intervenes at some point and you have to step away from the project for a few days or weeks. It'll also help you explain the project to others in the future. It doesn't have to be beautiful, but try to capture as many of the decisions that you've made and the reasons behind them as you can -- what's obvious to you today won't be in a few months.

Once you have a design, you can get down to implementing it. Depending on your style, that might mean that you first write a set of tests, or jump right in and start work on the feature itself... but that really gets away from the scope of your question.

7

The SEFS - Self Expiring File System prototype implementation has been designed based on the freely available FUSE file system. I have done this for my Masters Degree in Computer Science.

4

I've done similar things several times in the past, always with a daemon or cron job. I haven't seen (or at least noticed) any file systems that support an explicit expiry date, I always had to go on the last-accessed time. It's simple enough to have a cron job that simply executes find $search_path -atime +3 -exec rm {} \;, but there are lots of ways you could improve on that.

4

Just create a cron job to delete every file in the global tmp folder of your system if it is older than 14 or 30 days (it is important to have a special folder for this, where it is transparent for everyone that the lifetime of the files living there is limited). If someone wants a file not to be deleted automatically, he just should not save it in the tmp folder.

This was standard on the UNIX systems I had to work on more than 20 years ago. Since there were several users that time, all working on one machine using dumb terminals, and storage was expensive those times, automatic clean-up was very important to keep the system running.

2

You could add the option to right-click on a file and set the expiration time via a preset list of (1 day, 2 day, 3day, 4day, 5day, 1 week, 2weeks, 1month, X days). After someone adds the expiration time you should have it stored in a file (ex: C:\Program Files\Files Expire\files_to_expire.dat) and have the format of (added time_stamp, expire_time, file location).

Then set up something that will cycle through and read that file every few hours as instantaneous would not be required.

You can also have the files moved to a directory and compressed instead of deleting and allow a GUI to go back to old files and retrieve them upon request. You can also set a max space or time of the old files folder and it will delete them permanently eventually.

1

I suppose people that run servers or other space constrained systems run scheduled batch jobs to check for files that need to be deleted.

The IBM MVS operating system (now z/OS) has the ability to automatically delete expired data sets.

1

I've set up my webserver with a directory specifically for files which I'm offering for download for a limited time.

crontab:

@daily /path-to-script/autoexpire.pl >/dev/null 2>&1

autoexpire.pl looks into that directory for files with the pattern *_expYYYY-MM-DD.* (such as file-for-Joe_exp2013-11-30.doc). Any files named explicitly with such an expiry date in the filename will be deleted once the expiry date is in the past.

#!/usr/bin/perl -w
use strict;

my $expdir="/path-to-my-static-webpages/htdocs/autoexpire";
my $today=`date +%Y-%m-%d`; chomp $today; # get date (human readable)
my $t=$today;
$t=~s/-//g; # make date numeric for comparison

chdir($expdir) or die "$!";
my @files = glob("*_exp*");

foreach my $file (@files){
        next unless($file=~/\W/);
        if($file=~/_exp(\d\d\d\d-\d\d-\d\d)\./){
                my $f=$1;
                $f=~s/-//g; # make expiry numeric for comparison
                print "checking $file against $today ... ";
                if($f < $t){
                        print "$f < $t. unlinking.\n";
                        unlink("$expdir/$file");
                }else{
                        print "$f !< $t. ignoring.\n"
                }
        }
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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