• 22nd September 2009 - By dan

    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:
    • Digg
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • E-mail this story to a friend!
    • LinkedIn
    • Live
    • Reddit
    • StumbleUpon
    • Twitter
    • Yahoo! Bookmarks

Ad