Web Hosting Forums

Results 1 to 6 of 6

This is a discussion on Cron job to delete files in the Hosting Talk & Chit-chat forum
I've never used cron jobs before, can someone verify this is right? Right now all emails that are marked as spam for my domain get ...

  1. #1
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    564

    Cron job to delete files

    I've never used cron jobs before, can someone verify this is right?

    Right now all emails that are marked as spam for my domain get filtered to a spam email box. I'd like to run a cron job to delete those that are a certain age (say 30 days). After looking through some cron tutorials, here's the command I came up with:

    find /home/myAccount/mail/example.com/spam/cur -mtime +30 -exec rm {} \;

    Is that going to do the job properly?

  2. #2
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,661
    I dunno. Give it a try... HOWEVER...

    Be extremely careful with 'rm'!!!

    It's entirely possible to delete your whole web site (accidently) using 'rm'...

    When you're testing stuff like this, use 'ls' instead. Then, when you've got it aced, use 'rm'.
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL 2010

  3. #3
    Ron
    Ron is offline
    Loyal Client
    Join Date
    Aug 2002
    Posts
    7,503
    Quote Originally Posted by Vin DSL View Post
    When you're testing stuff like this, use 'ls' instead. Then, when you've got it aced, use 'rm'.
    Eeeeeeexcellent suggestion.
    Good luck

  4. #4
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    564
    Quote Originally Posted by Vin DSL View Post
    When you're testing stuff like this, use 'ls' instead. Then, when you've got it aced, use 'rm'.
    Ron's right, that IS a great idea. I just added the cron job (using 'ls'). Thanks Vin.

  5. #5
    Loyal Client
    Join Date
    May 2002
    Location
    Wisconsin, USA
    Posts
    564
    Quote Originally Posted by JonathanB View Post
    I'd like to run a cron job to delete those that are a certain age (say 30 days). After looking through some cron tutorials, here's the command I came up with:

    find /home/myAccount/mail/example.com/spam/cur -mtime +30 -exec rm {} \;
    In case anyone's interested...

    This did the job. I first used 'ls' as Vin described above, and everything looked good. Changed it back to 'rm' and it's been working great.

  6. #6
    Yeah, I know a LOT! Vin DSL's Avatar
    Join Date
    Mar 2003
    Location
    Arizona Uplands
    Posts
    10,661
    ~Cool

    Thanks for the update!
    DISCLAIMER Any resemblance between the views expressed above and those of the owners and operators of this system is purely coincidental. Any resemblance between these views and my own are non-deterministic. The existence of Vin DSL is questionable. The existence of views in the absence of anyone to hold them is problematic. The existence of the reader is left as an exercise in the second-order coefficient.

    No Guts, No Story! VinDSL 2010

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •