-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Minor cleanup on free-disk-space.sh #27088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ function free_up_disk_space_ubuntu() | |
| 'google-chrome-*' | ||
| 'libmono-*' | ||
| 'llvm-*' | ||
| 'man-db' | ||
| 'mysql-server-core-*' | ||
| 'powershell*') | ||
|
|
||
|
|
@@ -22,16 +23,29 @@ function free_up_disk_space_ubuntu() | |
| sudo apt-get autoclean -y | ||
|
|
||
| echo "Removing toolchains" | ||
| sudo rm -rf \ | ||
| /usr/local/graalvm \ | ||
| /usr/local/lib/android/ \ | ||
| /usr/share/dotnet/ \ | ||
| /opt/ghc/ \ | ||
| /usr/local/share/boost/ \ | ||
| "${AGENT_TOOLSDIRECTORY}" | ||
|
|
||
| echo "Prune docker images" | ||
| sudo docker system prune --all -f | ||
| directories_to_be_removed=( | ||
| "/usr/local/graalvm/" | ||
| "/usr/local/lib/android/" | ||
| "/usr/share/dotnet/" | ||
| "/opt/ghc/" | ||
| "/usr/local/share/boost/" | ||
| "${AGENT_TOOLSDIRECTORY}") | ||
|
|
||
| delete_directories_with_rsync "${directories_to_be_removed[@]}" | ||
|
|
||
| echo "Prune docker images" | ||
| sudo docker system prune --all -f | ||
| } | ||
|
|
||
| function delete_directories_with_rsync() | ||
| { | ||
| sudo mkdir /tmp/empty | ||
| for dir in "$@"; do | ||
| echo "Deleting contents of $dir using rsync" | ||
| sudo rsync --delete -a /tmp/empty/ "$dir" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would we want to use rync when all we want is rm? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the number of files in a directory is large, them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would rsync be faster than rm? is it because it does different system calls, it runs things in threads (good for networks), or? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I asked the ai and give context "work with data heavy systems", it answer: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my ai insist there is no system call to delete files in bulk... either can be wrong (or both) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't delete them in bulk - In short we found |
||
| sudo rmdir "$dir" | ||
| done | ||
| sudo rmdir /tmp/empty | ||
| } | ||
|
|
||
| echo "Disk space usage before cleaning:" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.