Tuesday, 8 May 2018

remove file using script

#!/bin/bash
TIME=`date +%b-%d-%y`            # This Command will add date in Backup File Name.
FILENAME=backup-$TIME.tgz    # Here i define Backup file name format.
SRCDIR=/var/www/html                    # Location of Important Data Directory (Source of backup).
#DESDIR=/var/www/backup            # Destination of backup file.
DESDIR=/home/backup            # Destination of backup file.
tar -czf $DESDIR/$FILENAME $SRCDIR 
#find /var/www/backup/* -mtime +5 -exec rm {} \;
find /home/backup/* -mtime +5 -exec rm {} \;
#END

No comments:

Post a Comment