Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.