Skip to content

Commit 14c9f52

Browse files
author
Ankam Ravi Kumar
authored
Create morethanxdays.sh
1 parent 1e49574 commit 14c9f52

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

morethanxdays.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
## Delete the Directories older than 2 days based on directory name validation
3+
## Refer YouTube Link for Explanation https://youtu.be/1Sh6PWcgXAA
4+
ls -ltr /fullbackup/archive/ | awk '{print $9}' > /scripts/dirs
5+
for i in `cat /scripts/dirs`; do
6+
STARTTIME=$(date +%s -d"$i 00:00:00")
7+
ENDTIME=$(date +%s)
8+
echo $((ENDTIME-STARTTIME)) | awk '{print int($1/60)}' > /scripts/value
9+
COUNT=`cat /scripts/value`
10+
if [ $COUNT -gt 2880 ]; then
11+
echo "Directories are older than 2days $i" >> /scripts/joblog
12+
rm -rf /fullbackup/archive/$i
13+
fi
14+
done

0 commit comments

Comments
 (0)