RE: bash script help: how to find mm-dd-yy of seven days ago?

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

 



Here's a line that I use to keep 14 days worth of logs.  

find /path/to/whatever -name 'name_of_file' -mtime +14 -exec ls -l {} \;
-exec rm {} \; >>$outp

HTH
Regards, Marshall

-----Original Message-----
From: Chris W. Parker [mailto:cparker@xxxxxxxxxxxx] 
Sent: Thursday, November 04, 2004 3:51 PM
To: redhat-list@xxxxxxxxxx
Subject: bash script help: how to find mm-dd-yy of seven days ago?


hello,

i'm trying to write a simple script that will delete all files that are
seven days old on a daily basis.

each time the script is run it will add one new file (format:
10-04-04.gz) to an ftp location. before the script adds a new file i
want it to delete the file that was added 7 days ago. the point of all
this is to have a history of at least 6 days at any given time.

at this point i have managed to get the current timestamp from date with
'date +%s'. i can also subtract seven days worth of seconds (604,800)
from that timestamp. but what i don't know how to do is feed the new
timestamp back into 'date' and have it return a date formatted like
%m-%d-%y. i don't think 'date' even supports what i want to do, but i
can't find a command that does.

any help would be appreciated.


thanks,
chris.

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux