Skip to content

Instantly share code, notes, and snippets.

@gonzalo-trenco
Created August 10, 2018 07:13
Show Gist options
  • Save gonzalo-trenco/5519cde9da433311e0ae275b45e6e631 to your computer and use it in GitHub Desktop.
Save gonzalo-trenco/5519cde9da433311e0ae275b45e6e631 to your computer and use it in GitHub Desktop.
Clean releases directories over 4 days old
#!/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