logo

Housekeeping

logo

Apologies again for the lack of updates – has been a bit hectic here and as I havent really been doing any coding, I havent had much useful information.

So today I thought I would share some Linux Pearls of wisdom, many people need to create housekeeping scripts that clean up certain directories every so often.

Many Perl advocates will tell you that banging a load of Regex into perl will do it simply.

I disagree – POSIX gives you plenty of tools to do 99% of the tasks you need – its just a case of knowing which ones you should be using.

To get you started here are 2 of the most used:

find /your/dir/here -mtime +30 -exec ls {}\;

Lists all files modified more than 30 days ago (clearly you can replace ls with rm to delete these!)

find ./ -type f -atime +365

This finds any files that havent been access for over a year, obviously you can pipe / exec this with something else.

Hope this helps!

Share with your friends and help out this site:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • E-mail this story to a friend!
  • Identi.ca
  • LinkedIn
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
logo
logo
Powered by Nu Order Webs