A comprehensive system cleaning script for macOS. Safely removes unnecessary cache, logs, and temporary files to free up disk space.
Türkçe README için tıklayın | Click for Turkish README
- 🗑️ Purgeable Space Cleanup: Time Machine snapshots and purgeable files
- 🌐 Chrome Cleanup: Service Worker caches and IndexedDB files
- 📝 System Logs: Cleans system and application logs
- 💾 Cache Cleanup: Removes user and application caches
- 🛠️ Xcode Cleanup: DerivedData, Archives, and iOS DeviceSupport files
- 🎵 Application Caches: Discord, SoundCloud, and other apps
- 📊 Detailed Report: Shows freed disk space
- macOS operating system
- Terminal access
- Sudo privileges for some operations
Run directly from your terminal without cloning:
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/oguzoldev/macos-cleaner-script/main/script.sh)"This command downloads and executes the script directly from GitHub.
git clone git@github.com:oguzoldev/macos-cleaner-script.git
cd macos-cleaner-scriptchmod +x script.shTwo versions available:
script.sh- Englishscript_tr.sh- Turkish (Türkçe)
./script.sh
# or for Turkish
./script_tr.shTo clean system logs and protected files:
sudo ./script.sh
# or for Turkish
sudo ./script_tr.sh======================================
Initial: 45.23 GB free space
======================================
======================================
Starting system cleanup...
======================================
[1/6] Cleaning Time Machine local snapshots (purgeable space)...
[2/6] Cleaning Chrome cache and databases...
[3/6] Cleaning system logs...
[4/6] Cleaning user caches...
[5/6] Cleaning Xcode files...
[6/6] Cleaning application caches and other files...
======================================
Cleanup completed!
======================================
Final: 52.18 GB free space
✅ Freed space: 6.95 GB
- Data Loss Risk: This script permanently deletes files. Back up important data.
- Chrome Sessions: Some Chrome sessions may be closed.
- Xcode Projects: Projects may need to be recompiled after DerivedData cleanup.
- System Files: Sudo privileges required to delete some system files.
- Time Machine local snapshots
/private/var/vm/sleepimage(sleep image file)~/Library/Caches/com.apple.bird- System periodic maintenance tasks
~/Library/Application Support/Google/Chrome/*/Service Worker/CacheStorage~/Library/Application Support/Google/Chrome/*/IndexedDB~/Library/Application Support/Google/Chrome/OptGuideOnDeviceModel
/Library/Logs/*/private/var/db/diagnostics/private/var/folders/*/private/var/log/*
~/Library/Caches/*~/Library/Logs/*~/Library/Caches/Homebrew/downloads
~/Library/Developer/Xcode/Archives~/Library/Developer/Xcode/DerivedData~/Library/Developer/Xcode/iOS DeviceSupport
~/Library/Application Support/SoundCloud/Cache~/Library/Application Support/discord/Cache~/Library/pnpm~/Library/Metadata/CoreSpotlight
You can customize the script for your needs. Open script.sh and comment out or remove lines you don't want to clean.
Example:
# rm -rf ~/Library/Caches/Homebrew/downloadsContributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/newFeature) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature/newFeature) - Create a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
Yes, the script only cleans cache and temporary files. However, we recommend reviewing the contents before use.
Run it when you experience disk space issues or once a month.
No, deleted files are permanently removed. Back up important data.
Tested on macOS 10.14 (Mojave) and later.
macOS's System Integrity Protection (SIP) feature protects some system files. Safari cache, HomeKit, CloudKit, and other Apple service caches cannot be deleted even with sudo. This is normal and important for your system's security. The script automatically hides these errors.
Thank you for using this script! Feel free to open an issue to report problems or make suggestions.
⭐ Don't forget to star if you like it!