LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-03-2012, 09:56 AM   #1
sonichedgehog
Member
 
Registered: Oct 2007
Location: London UK
Distribution: Fedora Core 17
Posts: 298

Rep: Reputation: 32
Assigning expiry dates to files


I would like to keep space free by deleting unwanted files- instead of either going through and deleting when my working folders are too big, or just deleting everything above a specified age - or not accessed for, say, 1 year- I want to specify how long I want to keep a file.

My scripting is basic at best, so at present I have:
Code:
#!/bin/bash
clear
echo "deleting files older than specified expiry times"
find /{location specified}/3month -mtime +91 -exec rm {} \;
find /{location specified}/6month -mtime +182 -exec rm {} \;
find /{location specified}/1year -mtime +365 -exec rm {} \;
I.e. I have a collection of trash directories.

Other methods that occur to me:
put the name of the file I want to expire into a configuration file, with an expiry date and design a script to load this information then delete the files if their atime is older than the expiry date. This means getting variables from a file- I might be stretching bash beyond what it's designed for? If anyone can point me to a link showing a way forward that will be most helpful.

-something like debugfs to manipulate the ctime? At present I feel that the use of debugfs for this would be dangerous

It's OK for now, but I'd be interested to see how other linux users are doing this. Most of us keep far too much data, bunging up our hd's and our backups, and pinging ceaselessly to and from the cloud. Be great to deal with this more efficiently.

Cheers
 
Old 06-04-2012, 03:21 AM   #2
Babertje
Member
 
Registered: Jun 2009
Location: Haarlem, The Netherlands
Distribution: Archlinux
Posts: 125

Rep: Reputation: 20
See man touch
touch can also alter the time of a file
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I need help with a script to list deleted files with dates JangoFett353 Linux - Newbie 13 03-31-2011 11:19 AM
rsync files with dates after a certain date anon091 Linux - Newbie 5 06-09-2010 02:04 AM
preserving dates when backing up files newbiesforever Linux - General 8 08-17-2007 12:17 AM
Copying files based on dates DIMonS Programming 6 08-10-2007 07:28 AM
To get the dates of downloaded files grautu Linux - Desktop 1 12-30-2006 09:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration