Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes my hard drive gets low on space, and various things don't work properly until I empty the Trash and free up some space. I know there are applications that empty the Trash after a set interval—but what I want is an app or script (or other means) to empty the Trash whenever there's e.g. less than 2GB of free space on a given hard drive.

share|improve this question
Why not buy a bigger hard drive? 1TB is well under $100 these days... :) – Piko Apr 16 '11 at 6:26
3TB is now under $100. – JoeTaxpayer Mar 27 at 2:15
And yet (a) they're all still finite, and (b) none of them can be added to the current MacBook Pro. – Gabe Mar 27 at 10:59
up vote 4 down vote accepted

I use a third party preference pane Compost that deletes from trash when the disk fills up or if the file has been in trash for a given time.

The original download stopped working for me but I have just found this on the author's site instead of the distributer. Note the author's comment

Compost is in a bit of a state of flux right now. The distributor has moved on to a different market and we wish them well in their endeavors. Additionally, the changes necessary to fully support Snow Leopard have been going through an extensive beta period as a result of the degree and complexity of changes required. Please stay tuned for more information.

So it might not work even from this download

When I updated this I had just installed it on Yosemite and it installed (but not enough time to see if it deleted anything) I have now updated to El Capitan and the installer fails.

share|improve this answer
For me it is "Hazel" that I use - wonderful automation tool. – Garex Mar 13 '15 at 12:43

You could also edit the crontab with EDITOR=nano crontab -e and add a line like

0 * * * * osascript -e 'tell app "Finder" to empty trash if free space of startup disk < 2.0E+9'

Hazel supports keeping the trash under a certain size or keeping items only for a period like two weeks.

share|improve this answer

I use CleanMyMac, though there are lots of others that do a similar job. CleanMyMac also cleans cache, etc. Hazel is also good for cleaning out folders that fill up with rubbish quite frequently.

share|improve this answer
Link? (10 more to go...) – Jason Salaz Oct 3 '11 at 3:19

That's an interesting question.

I wrote a little shell script that will empty the trash if the available disk space falls before a threshold defined in the script (default is 10 GB but you can change that by editing the script).

Install script

  1. Download this:

  2. Install it to /usr/local/bin/etilds.zsh

  3. Then do chmod 755 /usr/local/bin/etilds.zsh

Use launchd for automatic trash emptying

If you want this to run automatically, I recommend launchd. To do that

  1. Download this

  2. Move it to ~/Library/LaunchAgents/

  3. Tell it to run via launchctl load ~/Library/LaunchAgents/com.tjluoma.etilds.plist

It will run every 5 minutes (300 seconds) by default. You can edit that too.

To uninstall:

delete /usr/local/bin/etilds.zsh and ~/Library/LaunchAgents/com.tjluoma.etilds.plist and reboot.

Notes and Disclaimer

  • No guarantees or warranty but it works for me. Use at your own risk.

  • You have to edit etilds.zsh. Read it and you'll understand what to do.

  • "etilds" stands for "Empty Trash If Low Disk Space" because a) I couldn't come up with a better name and b) it seemed a sufficiently unix-y acronym.

share|improve this answer
All the links are gone making this useless – Mark Nov 10 '12 at 12:32
The links have been restored. I'm not sure why Dropbox stopped serving the old ones, but the new ones are on my own server, so they should be there for the foreseeable future. (If there is a better way to share files on ASE, please let me know.) – TJ Luoma Nov 11 '12 at 23:53
You can include the files directly in your post, maybe shorten the .zsh script down to the essential 5 lines first (and keep the link to the long version). So the answer remains usable even if your site goes down/offline for whatever reason. – patrix Nov 12 '12 at 21:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.