I have situation that I had originally thought would be easily remedied until I learned more about how -mtime actually works.
We have one server that collects backups from a number of other servers. The backup server is limited in space (for reasons that predate my employment). The standard here is to maintain 5 days worth of backup folders in each subdirectory.
Also- I should mention that this is a Windows server and I am using cygwin to run linux scripts.
For the purpose of example, here is the how the directory structure is setup;
g/backup/subdir
Within subdir, the backups directories simply have dates, so under subdir, you'd see;
The goal is to maintain 5 days and delete the 6th day's folder...
The script that I have setup to run against a directory like this is;
Now- here's the catch. The backup folders (2010-6-15) don't all get created at the exact same time. In fact for some, the times can vary greatly- from 7pm to 3am. This is where I think it breaks down when trying to use -mtime, since it's actually looking at the number of seconds, not the date on the folder.
I started trying to figure out a way of creating a file count variable, such as;
Again, I'm stuck with trying to figure out how to delete by date.
Sorry if this post is too wordy or if I've left out info. This marks my first post in a forum as I can usually figure these things out.
If anyone has any ideas or some better direction, it would be much appreciated.
thanks.
Last edited by vbe; 06-14-2010 at 12:21 PM..
Reason: code tags please
I have been working on a script to list all the name's of a subfolder in a text file then edit that text file and then delete the subfolder base on the edited text file so far I have been able to do every thing I just talked about but can't figure out how to delete the subfolers base on a text file... (8 Replies)
Hi,
I am trying to write a shell script to delete logs generate by db when space in the folder reaches 70%. i am getting space values from db, find the files at OS and remove them by using a cron job runs every 5minutes.
I have to keep the latest 5 files at any time, my problem is that log files... (3 Replies)
Hi ,
I need a script which basically deltes all files in folder a which are alreasy present in folder b
say folder a has files abc.txt
pqr .txt
and b has abc.txt
pqr.txt
rmr.txt
then file abc.txt and pqr.txt from a should be deleted (6 Replies)
hi
can any one help me in shell scripting
where in my requirement is to
write a shell script where in if i run that script i should copy all the .doc files from one system to another systems within a network like from parent folders to child folder
example
parent folder A within parent folder... (5 Replies)
Hi Experts,
i need a little help.
i have different folder that contain files that need to be deleted. but those folder contains huge amoung of same with 3 different extention.
what i used to do is to delete them using the rm commande
rm *.ext *.ext1 *.ext3
what i want to do is to have... (1 Reply)
hi i need a script to delete the files older than 2 days...
if my input is say in a folder versions
A_14122012.txt
A_15122012.txt
A_16122012.txt
A_17122012.txt
i want my output to be
A_16122012.txt
A_17122012.txt
thanks in advance
hemanth saikumar. (2 Replies)
Hi,
I currently use a script to extract *.deb files located in a Directory called
"/var/mobile/Media/Downloads"
The Problem is howver I want the script to ignore the folder:
"/var/mobile/Media/Downloads/New Debs and Files"
(it shall NOT decompile any of the files in that folder.
Here is... (2 Replies)
I am trying to copy files with specific date and name to another folder. I am very new to shell scripting so i am finding it hard to do that. see the sample code i have written below.
srcdir="/media/ubuntu/CA52057F5205720D/Users/st4r8_000/Desktop/office work/26 nov"... (13 Replies)
Hi Team,
I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder.
Eg:
parent folder --> /Interface/data/test/IN
Sub folder -->/Interface/data/test/IN/Invoice20180607233338
Subfolder will be always with timestamp... (6 Replies)
Hi,
I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content.
for example... (3 Replies)