• Post Reply Bookmark Topic Watch Topic
  • New Topic

c shell aging script  RSS feed

 
Shane Burgel
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone know how to write a basic script to check the dates of files in a directory and then delete any older than a specified amount of time?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many Linux distros already have such a tool called "tmpwatch". On my Red Hat 8.0 installation, this is located in /sbin, iirc. (I'm not at my own machine at the moment.)

HTH

Layne
 
Shane Burgel
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I guess I should have been more specific. I'm running on a unix system, not linux
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I primarily use Linux, except on a few machines at school. I apologize for making that asumption. Still, have you looked if your Unix flavor comes with tmpwatch?
 
Shane Burgel
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, and I don't see it, but thanks for the idea.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well - I have this one:


which runs fine on linux.
I don't know if your unix has bash and find, and if they behave similar.
-maxdepth 1 means not to visit subdirectories. Remove it, if it disturbs.
Test it carefully - I don't guarantee anything.
[ August 24, 2004: Message edited by: Stefan Wagner ]
 
Shane Burgel
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that got me the start I needed, and it appears to be working now.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!