Im truly sorry for this horrible title, it's the best I could phrase it.
So I have a backup scripts that creates backup tars of some server data and stores it in /server/backups, however I only need backups of the last week, therefore I created this script to run as a weekly task and clean up my backups folder:
#!/bin/bash
#initializing a with the amount of backup archives and b with the target max
a=find /server/backups/ -type f | wc -l
b=14
#if there are more backup files than target max
#delete the oldest files
if [ $a > $b ]
then
ls -1t /server/backups/ | tail -n +15 | xargs rm -f
fi
but it doesn't work. Im very new to linux and i dont know how to "debug" this.
-lt
and not>
– pLumo Nov 06 '19 at 12:25