Search code examples
shellubuntuerase

shell script to erase backups on ubuntu


I have this little script which is supposed to erase backups older then one month which are stored in a folder. But it doesn't work. Files are sql.gz File name example: CUSTOMER_2015-01-12-09:05.sql.gz

NOW=$(date --date '1 month ago' + '*%Y-%m*.sql.gz')
rm -rf /home/path/CUSTOMER_$NOW

Solution

  • You have a extra space after + that is why it is not working

    NOW=$(date --date '1 month ago' +'*%Y-%m*.sql.gz')
    rm -rf /home/path/CUSTOMER_$NOW