MacOS – ny way of limiting the space devoted to log files

macos

Is there any way of limiting the space devoted to log files?

I was running a little short of disk space and checked where it was used (if anyone is interested the following shows directories > 1GB) sudo du -hxd1 ~/Library/Developer | grep 'G\t'

I discovered ~/Library/Logs/CrashReporter was using almost 2GB (much of this seems to have been migrated from a Mavericks installation – even less than useless). Manually pruning this seems to be inordinately time consuming. I would like to automatically limit this to a reasonable size.


The vast bulk of the logs are in ~/Library/Logs/CrashReporter/MobileDevice either mobileassetd or JetsamEvent and refer to an iPhone or iPad, and seem to be of little value on the Mac.

Best Answer

Since we are talking about the result of application crashes, if such files keep on building up, I would pursue the reason of why this happens in the first place. Once fixed, just dump the files manually and move on.

On a stable system, the folder ~/Library/Logs/CrashReporter should be empty. Having almost 2 GB of crash dumps means that there is (or was) something wrong.

As you probably know, log files and crash dumps can be used to diagnose issues on your computer in order to repair said issues. Blindly removing them, will get you some disk space back, but the original issue will still be there and you will not be happy on the long run.

Due to the reason mentioned above (second paragraph of this answer), there is no automated task to limit the space for those files. You could, if you are into scripting or Automator (or both), write a script or Automator Folder Action workflow (or a combination of both) and watch that folder's size and when reaching a threshold removing the oldest entries.