[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
- Subject: RE: [cobalt-users] help - making a cron job to auto delete files, earlier than a specific date
- From: Greg Hewitt-Long <greg@xxxxxxxxxxxxxxxxxxx>
- Date: Thu Aug 9 11:50:05 2001
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
> > OK, it could go something like this:
>>
>> ------------cut below this line------------
>> #!/bin/bash
>>
>> 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????
>
>Colin,
>
>This looks like the goods.
>
>I just changed the last line to read...
>find /home/sites/www.domain.com.au/web/pdf -type f -ctime +15 | xargs rm
>*.pdf
>
>Assuming I put the correct 'www.domain.com.au' in the line instead, this
>should delete all the files ending in '.pdf' if older than 15 days???
No - all files with a ctime older than 15 days - use mtime to be sure - for a list of the time attributes, type `man find` at the prompt.
>Now for possibly a stupid question, how can I, ummmmm, age some pdf files so
>they are older than 15 days??? For testing purposes...
you can't - but you can make a bunch of files that are older than a certain number of minutes - which you can also learn about using `man time`
For instance - just incase cobalt/linux ever becomes 'standard' to unix standards - you might want to put in -print at the end of the find command - also - ALWAYS use the time configuration letters when using ctime, mtime, atime etc - ie, EXPLICITLY specify days, months, weeks, hours, minutes etc - just INCASE they ever change the command in some kind of update.
Being NON-SPECIFIC is the mother of all programming/scripting/coding screw ups.
regards
Greg
--
http://www.webyourbusiness.com/
Providers of E-Commerce Software &
Web Design Consultancy and Services.
PH: (970)266-0195 FAX: (970)266-0158