linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* oldest file
@ 2003-02-06 10:01 Mat Harris
  2003-02-06 16:37 ` Scott Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: Mat Harris @ 2003-02-06 10:01 UTC (permalink / raw)
  To: linux-admin

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

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.

-- 
Mat Harris			OpenGPG Public Key ID: C37D57D9
mat.harris@genestate.com	www.genestate.com	

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: oldest file
  2003-02-06 10:01 Mat Harris
@ 2003-02-06 16:37 ` Scott Taylor
  2003-02-06 16:42   ` Mat Harris
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Taylor @ 2003-02-06 16:37 UTC (permalink / raw)
  To: linux-admin

At 02:01 AM 2/06/03, Mat Harris wrote:
>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 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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: oldest file
  2003-02-06 16:37 ` Scott Taylor
@ 2003-02-06 16:42   ` Mat Harris
  2003-02-06 16:55     ` Scott Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: Mat Harris @ 2003-02-06 16:42 UTC (permalink / raw)
  To: Scott Taylor; +Cc: linux-admin

[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]

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

On Thu, Feb 06, 2003 at 08:37:55 -0800, Scott Taylor wrote:
> At 02:01 AM 2/06/03, Mat Harris wrote:
> >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 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Mat Harris			OpenGPG Public Key ID: C37D57D9
mat.harris@genestate.com	www.genestate.com	

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: oldest file
  2003-02-06 16:42   ` Mat Harris
@ 2003-02-06 16:55     ` Scott Taylor
  2003-02-06 17:16       ` Mat Harris
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Taylor @ 2003-02-06 16:55 UTC (permalink / raw)
  To: linux-admin

At 08:42 AM 2/06/03, Mat Harris wrote:
>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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: oldest file
  2003-02-06 16:55     ` Scott Taylor
@ 2003-02-06 17:16       ` Mat Harris
  0 siblings, 0 replies; 7+ messages in thread
From: Mat Harris @ 2003-02-06 17:16 UTC (permalink / raw)
  To: Scott Taylor; +Cc: linux-admin

[-- Attachment #1: Type: text/plain, Size: 1641 bytes --]

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.

On Thu, Feb 06, 2003 at 08:55:07 -0800, Scott Taylor wrote:
> At 08:42 AM 2/06/03, Mat Harris wrote:
> >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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Mat Harris			OpenGPG Public Key ID: C37D57D9
mat.harris@genestate.com	www.genestate.com	

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: oldest file
@ 2003-02-06 17:39 Scott Taylor
  2003-02-06 21:46 ` Mat Harris
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Taylor @ 2003-02-06 17:39 UTC (permalink / raw)
  To: linux-admin

At 09:16 AM 2/06/03, you wrote:
>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.

You could still use find, it can go by the minute if you like.

ls -alt|head -5
will give you the 5 most recent files (usually . and .. first)
ls -alt|tail -5
will give you the 5 oldest



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: oldest file
  2003-02-06 17:39 oldest file Scott Taylor
@ 2003-02-06 21:46 ` Mat Harris
  0 siblings, 0 replies; 7+ messages in thread
From: Mat Harris @ 2003-02-06 21:46 UTC (permalink / raw)
  To: Scott Taylor; +Cc: linux-admin

[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]

that's it. that'll do i perfectly. just a little bit of looping and perl and
it's sorted.

cheers scott

On Thu, Feb 06, 2003 at 09:39:42 -0800, Scott Taylor wrote:
> At 09:16 AM 2/06/03, you wrote:
> >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.
> 
> You could still use find, it can go by the minute if you like.
> 
> ls -alt|head -5
> will give you the 5 most recent files (usually . and .. first)
> ls -alt|tail -5
> will give you the 5 oldest
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Mat Harris			OpenGPG Public Key ID: C37D57D9
mat.harris@genestate.com	www.genestate.com	

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-02-06 21:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-06 17:39 oldest file Scott Taylor
2003-02-06 21:46 ` Mat Harris
  -- strict thread matches above, loose matches on Subject: below --
2003-02-06 10:01 Mat Harris
2003-02-06 16:37 ` Scott Taylor
2003-02-06 16:42   ` Mat Harris
2003-02-06 16:55     ` Scott Taylor
2003-02-06 17:16       ` Mat Harris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).