We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e49574 commit 14c9f52Copy full SHA for 14c9f52
morethanxdays.sh
@@ -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