Automatic deletion of old files when disk is full
I am using the "motion" software to capture still images to a volume of limited size. The images are all roughly the same file size, and are in one directory. Since they will be triggered by movement in the camera view, the creation of the files will be random and sporadic.
I would like to set it up so that, when the volume is full, the oldest files will be deleted to make room for the new files. I was thinking of writing a script that would monitor the directory on a regular basis. When the amount of free space drops below 100MB, it would delete enough files to clear up 200MB of free space. (or something along those lines) I figure that somebody has had a need to do something like this before, but I haven’t been able to find anything as of yet. Any suggestions? Thanks. |
You can set script for this.
Thanks |
You could use the logrotate tool, which can be used to manage files generally, or set a cron job to use the find cmd, after using eg df to check disk space.
These will be useful http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
Better u need to use the script to delet the old file by the find command with option mtime or atime and schedule it by cronjob to run as per frequency of the file .
|
I figured somebody would have done this before, but I guess not. So, I wrote a script to do the trick:
Code:
I set it to run every 5 minutes. Seems to work fine so far. Thanks for the help. |
All times are GMT -5. The time now is 03:26 AM. |