Created
August 10, 2018 07:13
-
-
Save gonzalo-trenco/5519cde9da433311e0ae275b45e6e631 to your computer and use it in GitHub Desktop.
Clean releases directories over 4 days old
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# releases should be name after formatted timestamp | |
# date "+%Y%m%d%H%M%S" in order to work | |
time_margin=$(date -d "4 days ago" "+%Y%m%d%H%M%S") | |
for i in $( ls releases ); do | |
if [ "$time_margin" -gt "$i" ]; then | |
echo "$i will be removed" | |
rm -rf releases/$i | |
echo "$i removed" | |
else | |
echo "$i will prevail" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment