Skip to content

Commit d376bd1

Browse files
UlisesGasconjoyeecheungtargos
authored
feat: add clean up script for macos (#3481)
Co-authored-by: Joyee Cheung <[email protected]> Co-authored-by: Michaël Zasso <[email protected]>
1 parent 9c79d43 commit d376bd1

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tools/macos-cleanup.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
# Maintenance script for macOS
4+
# This script cleans up various caches, temporary files, and other cruft on macOS.
5+
# Custom script (forked from https://github.com/paulaime/CleanUpMac)
6+
# -- STEPS ---
7+
# Download/update the script: curl https://raw.githubusercontent.com/nodejs/build/main/tools/macos-cleanup.sh --output macos-cleanup.sh
8+
# Make the script executable: chmod +x macos-cleanup.sh
9+
# Usage: sudo ./macos-cleanup.sh
10+
11+
# Ask for the administrator password upfront
12+
if [ "$EUID" -ne 0 ]; then
13+
echo "Please run as root"
14+
exit
15+
fi
16+
17+
18+
echo 'Empty the Trash on all mounted volumes and the main HDD…'
19+
sudo rm -rfv /Volumes/*/.Trashes &>/dev/null
20+
sudo rm -rfv ~/.Trash &>/dev/null
21+
22+
echo 'Clear System Log Files…'
23+
sudo rm -rfv /private/var/log/asl/*.asl &>/dev/null
24+
sudo rm -rfv /Library/Logs/DiagnosticReports/* &>/dev/null
25+
sudo rm -rfv /Library/Logs/Adobe/* &>/dev/null
26+
rm -rfv ~/Library/Containers/com.apple.mail/Data/Library/Logs/Mail/* &>/dev/null
27+
rm -rfv ~/Library/Logs/CoreSimulator/* &>/dev/null
28+
29+
echo 'Clear Adobe Cache Files…'
30+
sudo rm -rfv ~/Library/Application\ Support/Adobe/Common/Media\ Cache\ Files/* &>/dev/null
31+
32+
echo 'Cleanup iOS Applications…'
33+
rm -rfv ~/Music/iTunes/iTunes\ Media/Mobile\ Applications/* &>/dev/null
34+
35+
echo 'Remove iOS Device Backups…'
36+
rm -rfv ~/Library/Application\ Support/MobileSync/Backup/* &>/dev/null
37+
38+
echo 'Cleanup XCode Derived Data and Archives…'
39+
rm -rfv ~/Library/Developer/Xcode/DerivedData/* &>/dev/null
40+
rm -rfv ~/Library/Developer/Xcode/Archives/* &>/dev/null
41+
42+
echo 'Cleanup Homebrew Cache…'
43+
brew cleanup --force -s &>/dev/null
44+
brew cask cleanup &>/dev/null
45+
rm -rfv /Library/Caches/Homebrew/* &>/dev/null
46+
brew tap --repair &>/dev/null
47+
48+
echo 'Cleanup symbolication cache'
49+
symbolscache delete --quiet
50+
51+
echo 'Cleanup any old versions of gems…'
52+
gem cleanup &>/dev/null
53+
54+
echo 'Purge inactive memory…'
55+
sudo purge
56+
57+
echo 'Remove Jenkins error logs…'
58+
rm /Users/iojs/jenkins_err.log
59+
60+
echo 'Remove workspace, it will be recreated again…'
61+
rm -rfv /Users/iojs/build/workspace/*

0 commit comments

Comments
 (0)