oldest file
i am sure this has been asked before, but I can't find trace of it in any archives.
I need to find the oldest directory inside multiply subdirectories. Perhaps I should explain...
I have /home/cams/
inside that dir is four other dirs: cam1 cam2 cam3 cam4 inside each of those is a directory structure like: year/day-date/
i want to run a script that searches for the oldest day in each cam directory.
What is the best way to do this.
btw, the oldest days are rm -rf'd when found.
Signature · 2 lines
Mat Harris OpenGPG Public Key ID: C37D57D9 [email protected] www.genestate.com
Quoted 6 lines · Mat Harris
i am sure this has been asked before, but I can't find trace of it in any archives.
I need to find the oldest directory inside multiply subdirectories. Perhaps I should explain...
Quoted 6 lines
I have
/home/cams/
inside that dir is four other dirs: cam1 cam2 cam3 cam4 inside each of those is a directory structure like: year/day-date/i want to run a script that searches for the oldest day in each cam directory.
What happens if the oldest day is the only file and that file is today's?
Wouldn't you rather just remove all files older than X number of days? You could do this with the find command; find files changed 20 days ago and more:
find /home/cams/ -ctime +20 -exec rm -rf {} \;
for more info:
man find
yes but the problem with that is that the day could be of variable size and I can't remove more than necessary so removing day 20 may be equivalent to removing days 19-15
Quoted 30 lines · Scott Taylor
Quoted 6 lines · Mat Harris
i am sure this has been asked before, but I can't find trace of it in any archives.
I need to find the oldest directory inside multiply subdirectories. Perhaps I should explain...
Quoted 6 lines
I have
/home/cams/
inside that dir is four other dirs: cam1 cam2 cam3 cam4 inside each of those is a directory structure like: year/day-date/i want to run a script that searches for the oldest day in each cam directory.
What happens if the oldest day is the only file and that file is today's?
Wouldn't you rather just remove all files older than X number of days? You could do this with the find command; find files changed 20 days ago and more:
find/home/cams/-ctime +20 -exec rm -rf {} \;for more info:
man find-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Mat Harris OpenGPG Public Key ID: C37D57D9 [email protected] www.genestate.com
Quoted 3 lines · Mat Harris
yes but the problem with that is that the day could be of variable size and I can't remove more than necessary so removing day 20 may be equivalent to removing days 19-15
You will need to learn Perl if you are trying to compare file names. I'm not sure how a day can be of variable size; unless there are more than 24 hours in some days and less in others? Otherwise, the filesystem knows the date the file was created and or modified, I don't understand why you couldn't utilize that (ls -alt).
Perhaps I still don't understand what you are trying to do; maybe another attempt at an example will help.
Scott.
i meant that more pictures could be taken on one day than others. I already know perl but the perl lists haven't got any ideas.
Let me try it from another angle. I want to keep disk usage at percentage level defined in $x.
I want to delete the oldest day in order to keep this level. I have to delete one day at a time, and only if a second usage check also show above the level, can i delete another day.
I have to keep deletetions to a minimum while keeping the disk healthy as people will want to keep their archives for as long as possible.
Quoted 21 lines · Scott Taylor
Quoted 3 lines · Mat Harris
yes but the problem with that is that the day could be of variable size and I can't remove more than necessary so removing day 20 may be equivalent to removing days 19-15
You will need to learn Perl if you are trying to compare file names. I'm not sure how a day can be of variable size; unless there are more than 24 hours in some days and less in others? Otherwise, the filesystem knows the date the file was created and or modified, I don't understand why you couldn't utilize that (ls -alt).
Perhaps I still don't understand what you are trying to do; maybe another attempt at an example will help.
Scott.
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Mat Harris OpenGPG Public Key ID: C37D57D9 [email protected] www.genestate.com