This is the crontab line as shown by crontab -l
Code: Select all
30 6 * * 2-7 find /sata/mongobackup -name "*memaback_archive.gz" -type f -printf "%T@\t%p\n" | sort -n | head -n -3 | cut -f 2- | xargs rm -f >> /sata/mongobackup/cron.log 2>&1
Details follow.
I have a directory /sata/mongobackup owned rwx by bob.bob which is populated by a daily backup of my mongodb by another cron job.
This is what I see this morning:
Code: Select all
bob@newisa:/sata/mongobackup$ ls -lha
total 11G
drwxrwxr-x 2 bob bob 4.0K Jun 9 06:00 .
drwxr-xr-x 5 root root 4.0K Jun 5 17:29 ..
-rw-r--r-- 1 bob bob 2.7G Jun 6 06:03 20230606-060001_memaback_archive.gz
-rw-r--r-- 1 bob bob 2.7G Jun 7 06:03 20230607-060001_memaback_archive.gz
-rw-r--r-- 1 bob bob 2.7G Jun 8 06:03 20230608-060001_memaback_archive.gz
-rw-r--r-- 1 bob bob 2.7G Jun 9 06:03 20230609-060001_memaback_archive.gz
Code: Select all
bob@newisa:/sata/mongobackup$ find /sata/mongobackup -name "*memaback_archive.gz" -type f -printf "%T@\t%p\n" | sort -n | head -n -3 | cut -f 2-
/sata/mongobackup/20230606-060001_memaback_archive.gz
Code: Select all
Debian 11.7
cron/stable,stable,now 3.0pl1-137 amd64
bash/stable,stable,now 5.1-2+deb11u1 amd64