delete files older than 7 days Except on saturdays
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ohh , thank you , but i must have misled you.
all the files are *.bak, the ones that are in normal days and the ones that are on saturdays.
so i can't identify them by name...
How are the backup files created?
How are the backup files named?
Are you just searching the current directory?
Some off the top ideas.
Append SAT to your backup file names and use the above posted find command that excludes SAT.
Create the Sat backup files in another directory. Limit the find command to not search that directory.
Loop through those files that are older then 7 days and check the atime/ctime. Delete those files not created on a Sat.
Thank you all! that is a great idea.
i'll just backup the saturday backups into a different folder and operate the "rm" on the regular backups folder.
i just need to be carefull not to delete the script itself, since it is inside the folder of the backup and older than 7 day
If you wish to keep the script in the same directory you could regen it via cron script (if file doesn't exist then make it [source elsewhere]). I would prefer to have any executable in some other centralized location, but that's just my preference.
I'm a bit out of touch with Linux/Unix, so please excuse me for referencing any obsolete commands/programs and such...
Last edited by Mark Nagel; 03-17-2014 at 01:30 PM.
Definitely keep the prog in a separate dir from data files eg backups.
Keeping the Sat backups in yet another dir eg 'weekly_archive' is also a good idea.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.