Just ran:
| 1 | #!/usr/bin/env bash |
|---|---|
| 2 | |
| 3 | # remove builds older than 60 days for 25 largest build directories |
| 4 | while read dir; do |
| 5 | sudo find ${dir} -maxdepth 1 -type d -regex '.*/[1-9][0-9]+' -mtime +60 -exec rm -r "{}" \; |
| 6 | done < <(du -chs /srv/jenkins/builds/* | sort -rh | head -n26 | tail -n25 | awk '{print $2}') |
| 7 | |
| 8 | # remove builds older than 30 days for 10 largest build directories |
| 9 | while read dir; do |
| 10 | sudo find ${dir} -maxdepth 1 -type d -regex '.*/[1-9][0-9]+' -mtime +30 -exec rm -r "{}" \; |
| 11 | done < <(du -chs /srv/jenkins/builds/* | sort -rh | head -n11 | tail -n10 | awk '{print $2}') |
| 12 | |
| 13 | # remove builds older than 21 days for 5 largest build directories |
| 14 | while read dir; do |
| 15 | sudo find ${dir} -maxdepth 1 -type d -regex '.*/[1-9][0-9]+' -mtime +21 -exec rm -r "{}" \; |
| 16 | done < <(du -chs /srv/jenkins/builds/* | sort -rh | head -n6 | tail -n5 | awk '{print $2}') |
to clean up old builds on contint1001.
Clean up should be automated and if it is automated then the settings may need to be revisited