-2

I am really horrible at programming or script writing but I have a few Linux based machines Ubuntu Debian etc.. In certain path locations I would like to run a script that removes files after 30 days.. I have a pretty good idea on how to use crontab -e but it's the script language that gets me baffled..

Here is an example of what I am working with..

So far I have been manually removing the files like this..

rm -r ./filename.wav

http://server.lorentedford.com/41715/

I suppose the real question is this possible to do? The other half of the issue is are their creation dates stored somewhere ls -l does not show creation date only the last time it's changed..

I noticed some negative feedback on the post but understanding the frustration of teaching the language..

Ok so i realized i forgot to add the most important part of this equazion and this was that chmod 775 gets run in these folders every minute.. Since technically that modifies things wouldn't this throw off the -mtime?

2 Answers2

0

The post 'How to delete files older than X hours' mentioned above has the answer for you. Just use -mtime +<days number> in the find command. You can also try the -atime or -ctime depending on your actual needs.

GMichael
  • 2,726
  • 1
  • 20
  • 30
0

UNIX has only last modify, last change (including last modify, but also ownership and access rights change) and last access dates in its filesystem, there is no creation date. Command "find -type f -mtime -30 ." will give you the list of files, which were modified in last 30 days.

Sergey Brodin
  • 361
  • 1
  • 7