In a backup directory I want to keep all 7 days generated files and want to delete the older days.
I tried with the -mtime option and observed the script for 3-4 days it was working. But after 5-6 days it stopped working. So deletion didnt happen and directory is full now. It seems like the -mtime is not working.
Please note also I have a cron running which automate this.
10 3 * * * su - cassandra -c /opt/cassandra/scripts/backup_cassandra >> /tmp/backup.log
Here is the script I m using :
#!/bin/bash
set -x
export PATH=/opt/dse/bin/:/usr/lib/jvm/jre-1.8.0//bin:/sbin:/usr/sbin:/bin:/usr/bin:/root/bin
. /opt/cassandra/.env # source functions & password
# First we delete backup files older than 8 days.
find /data_cassandra/cassandra/backup/ -name "dc_east__*" -mtime 8 -exec rm {} \;
# cd to where the scrips are.
cd /opt/cassandra/scripts/
# And start the backups.
./backup.sh start -all # Kick off a full backup
Please help in a solution to this.
-f
(force remove) flag torm
? – Kaffe Myers Feb 20 '22 at 19:38