Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I copied this from a blog entry, studied it, tweaked it a bit and more or less it works:


GZ_DATE=`date +%Y%m%d`
GZ_TIME=`date +%H`


# Find all files older than 7 days (10080 minutes) and remove them

find BK_PATH* -type f -mmin +10080 -exec rm {} \;

# Dump and gzip export of SQL data

mysqldump --lock-all-tables --all-databases -u backup -p backup | gzip > $BK_FILE

However it does not seem to delete backups which are

share|improve this question

closed as not a real question by voretaq7 May 6 '12 at 2:44

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

I'm closing this as it's only about half a post... finish your post and I'll happily re-open it :-) – voretaq7 May 6 '12 at 2:44
It does not delete backups which are what ? – Iain May 6 '12 at 6:10

Did you mean to post this? It looks unfinished.

It's not deleting files because the line you would expect to delete them - the find command, which executes rm on the matching files it finds - is commented out (starts with a #). It's being ignored.

share|improve this answer
The last sentence seems to have been chopped. Weird. In any event, it was of little relevance. It is commented out but even when it is not it still does not seem to delete dates backups? :s – Alex.Barylski May 6 '12 at 4:27

Uncomment find BK_PATH* -type f -mmin +10080 -exec rm {} \;

share|improve this answer

I assume that in the live version of this script, the find is not commented out (commenting a find -exec rm structure out in a pasted script is actually a good idea) ?

share|improve this answer
That would be correct this was done in error as I tested the script. I noticed just now the BK_PATH does not have the $ and no trailing slash is given. I changed that and now I will see what happens :) – Alex.Barylski May 6 '12 at 4:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.