0

I have a ubuntu server 12.10 which receives images from a camera by FTP, I receive the images in a directory with a fixed quote on the server and I need to delete the oldest images first, I would like to keep 1Gb free for new images.

I have followed this thread but cannot find the solution there.

autotrash would be a good command but I do not have gnome installed.

Does anybody have any suggestions?

  • 1
    The question you linked has plenty of good solutions for this problem. Can you detail which one you tried and why it didn't work for you? If it's a server, a crontab entry would be the best. If you know the image reception schedule the easiest way is to delete all files older than X days, if you have images of approximately the same size coming in at regular intervals you can easily figure out the needed "age" so that you have about 1 GB free at all times. – roadmr Jan 31 '14 at 17:32

1 Answers1

0

Your original question is "How to delete files and subdirectories by size and age". Use find:

This will delete all files under the current directory larger than 2 MB:

find ./ -size +2M -delete

This will delete all files created more than 7 days ago:

find ./ -ctime +7 -delete
roadmr
  • 33,892
  • 9
  • 80
  • 93