[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cobalt-users] help - making a cron job to auto delete files, earlier than a specific date



 > Wow what a subject line...
Yeah, it's specific and that's a "Good Thing" (tm) for archival purposes.
>
> Not sure if this is off topic or not, but hopefully you wonderful people
> will help me ;-)
As long as you're running it on a Cobalt box it is <chuckle>

> I need to create a daily cron job that will delete all files in a specific
> directory that are 15 days or older than the current date.

<snippage>

OK, it could go something like this:

------------cut below this line------------
#!/bin/bash
###########################################
#The Janitor
#A simple shell script to remove anything in the specified directory older
than 15 days
#to adjust age of files to be removed, change the ctime argument to the
desired number
#this means that files aged 0-14 days of age (measured from AT_DATE) will
remain
###########################################

find /home/sites/site#/web/grunge -type f -ctime +15 | xargs rm
------------cut above this line------------

Now cron it to run once a day and walla! 'yer done.
There are other ways, but this is a low overhead approach.
Other suggestions ladies and gentlemen????

Regards & HTH,
-Colin
--
Colin J. Raven