Last active
January 1, 2020 08:48
-
-
Save welsonla/0e4c4a818abfae0400a4087b54e81c43 to your computer and use it in GitHub Desktop.
清理本地磁盘快照
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 | |
#diskspace info | |
puts "Current Diskspace info:" | |
puts "---------" | |
puts %x[df -lh /] | |
#list localsnapshots | |
puts "\n\n---------" | |
list = %x[tmutil listlocalsnapshots /] | |
puts list | |
#delete snapshots | |
puts "\n\n---------" | |
puts "Start delete snapshots:" | |
matches = list.scan(/\d{4}-\d{2}-\d{2}-\d{6}/) | |
matches.each_with_index{|snapshoot,index| | |
puts "delete the listlocalsnapshots #{snapshoot}" | |
sh = "tmutil deletelocalsnapshots #{snapshoot}" | |
system(sh) | |
} | |
#diskspace info after delete snapshot | |
puts puts "\n\n---------" | |
puts "Diskspace info after delete snapshots:" | |
puts %x[df -lh /] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment