Okay, here is what I have:
#!/bin/sh
cd /opt/backup/app || exit
find . -name "*.tar" -mtime +7 -exec gzip {} \;
find . -name "*.war" -mtime +7 -exec gzip {} \;
find . -name "*.tar.back*" -mtime +7 -exec gzip {} \;
#find . -name "*.gz" -type f -mtime +91 -exec rm {} \;
Here is a little bit on what I want to do. The /opt/backup/app directory has many sub-directories with many more directories under them. Now, everything in these directories are backups of old files, in this case all the files I am looking to execute on are *.tar, .war. and *.tar.back
What I am doing now, is just gzipping anything older than 7 days, and deleting anything older than 91 days. Now, I ran into a situation where it would have been helpful to have one of these files after 91 days. So I was wondering how I would change this script to the following:
Run the find command(or some equivelant if it's easier that way), then a logic statement to say, if this .gz file is the only one in this directory, then do nothing, else delete all .gz files older than 91 days, but keep the most recently updated file.
lol, well I was going to write it in some kind of code-block, but then I didn't.