Skip to content

Instantly share code, notes, and snippets.

@welsonla
Last active January 1, 2020 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save welsonla/0e4c4a818abfae0400a4087b54e81c43 to your computer and use it in GitHub Desktop.
Save welsonla/0e4c4a818abfae0400a4087b54e81c43 to your computer and use it in GitHub Desktop.
清理本地磁盘快照
#/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