![]() ![]() # PLEASE ADD NEW CROND JOB AT THE END OF THIS FILE The above command will find and display the older files which are older than 30 day in the current working directory. oldfiles (/h/USER/.txt (NDm+30/)) if ( (oldfile)) then rm -f - oldfiles else echo >&2 No text files to del fi. rwxrwxr-x 1 deelip deelip 875 Oct 29 12:09 delete-app-backup.shĪfter that you need to set a cron scheduler for every day to run this script auto using below ~]$ crontab -e ![]() crontab -e 0 7 /bin/bash /opt/script/delete-old-folders.sh You will get an output like the one below. chmod +x /opt/script/delete-old-folders.sh Finally add a cronjob to automate this. Save the file contain & set executable permissions to script file using below command.Ĭhmod +x /home/deelip/sync-server-data/delete-app-backup.sh Set an executable permission to delete-old-folders.sh file. # Web server two application full backup details 30 days old files.įind /REMIT_FS02/datastorage/datastorage/Log-Automation-JBoss/Node53/APP -type f -name "*.bz2" -mtime +30 -delete # Web server one application full backup details 30 days old files.įind /REMIT_FS02/datastorage/datastorage/Log-Automation-JBoss/Node50/APP -type f -name "*.bz2" -mtime +30 -delete # Written by Deelipkumar Yadav on 29th November 2019 Tested on RHEL 6.x, RHEL 5.x, and Ubuntu Linux ![]() # A simple shell script to delete last 30 days backup files delete To manage disk usage, I need a bash script that will delete all files older than 1 month, but keep all files created on Mondays, even if they are older than 1. Vim /home/deelip/sync-server-data/delete-app-backup.sh Touch /home/deelip/sync-server-data/delete-app-backup.shĪfter that you need to add below contain inside delete-app-backup.sh file. Sept 1:- create bash script file using below command RT3070Guest Account Features: Upload 50 Files At a Time (500mb max), Mp3 and Mp4 Files Only, Max 500 Files Per Person, Direct Download Urls Last 30 days. +7 will then remove the files older than 168 hours. This can be run automate with the help of cron. However, I've just tested that and it looks like it doesn't only rely on the date info, but also on the hours and minutes. Here I am going to tell you how to delete backup files older than 30 days through bash scripts or command line, which help to save your system, server space & time. ![]()
0 Comments
Leave a Reply. |