[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-users] How to removing directories older than 7 days
- Subject: Re: [cobalt-users] How to removing directories older than 7 days
- From: Andreas Banze <andreas@xxxxxxxx>
- Date: Thu Aug 14 02:46:05 2003
- List-id: Mailing list for users to share thoughts on Sun Cobalt products. <cobalt-users.list.cobalt.com>
On Thu Aug 14, 2003 - 10:18:14AM, René Mølsted wrote:
> I need to remove directories older than 7 days at 23:59 every day
> The directories are named by date, eg. 2003-08-03
> I also need to run it as a Crontab or from cron.daily ;o)
two possibilities:
1. checkout man tmpwatch
2. use this script in cron.daily (it deletes not everything older than 7
days but all from exactly 7 days back - started every day this should not be
a problem):
/bin/sh
TIMESTAMP=$(date --date="1 week ago" +%Y-%m-%d)
rm -fr path/to/your/files/$TIMESTAMP
echo "deleted $TIMESTAMP"
change /path/to/your/files/ so it fits your setup
If you want to use crontab, go ahead, the man page (man 5 crontab and man
crontab) shoudl have any information you need.
MfG
Andreas Banze
--
There are two means of refuge from the miseries of life: music and cats.
-- Albert Schweitzer