16

After installing Mavericks, I discovered snapshot.db (1.5 GB) file in:

/var/db/systemstats/snapshots.db

What is the use of that file? Is it safe to delete it?

  • I have the same problem. 1.5 GB snapshot.db file. 27" iMac Core i7 with Mavericks. I sent in my "feedback" to Apple. I reported it as a bug. – user68955 Jan 29 '14 at 15:34
  • Just in case you don’t want to delete it, there is a discussion to trim down the size in this discussion (thanks @sayzlim) – nohillside Aug 13 '14 at 6:09
  • You can delete it after stopping the service as explained in here. – kenorb Nov 30 '15 at 20:44
13

At a high level, the file you listed is a binary database file used by the OS to track power usage, performance and sleep/wake data over time. Despite the general guidance to not delete anything from /var/db this appears to not cause undue harm if you were to delete that one file on occasion.

This feeds the new views of energy usage and perhaps might help with diagnostics if you have problems down the line and ask Apple to help diagnose the system.

The program that writes to that file (as well as associated files in /var/db/systemstats ) is systemstatsd.

You can use the systemstats --help command to get more details and read from that file if you are curious. The manual page I linked to is the shell of a manual page and the code is mostly undocumented by Apple other than the documentation that is build into the tool and accessible from calling it with the help option.

It's generally not safe to delete anything in /var/db since the system could depend on the files being coherent, but I've tested removing all contents of that directory by booting into Single User mode and the system seems to recreate things properly and handle any attempts to manually clean up these files.

I wouldn't recommend deleting anything from sytemstats on a Mac you are not ready to erase and reinstall and you also might get odd information from Activity Monitor if you manage to get the database and log files in an inconsistent state. That being said, it looks like the system was programmed defensively to handle things going missing from that directory and not cause erratic operation in general if you do so anyhow.

5

I filed a bug report with apple for the same issue. They responded that snapshots.db is intended to hold data for the last 3 days and reach 70-150 MB on most systems. However, on mine (OS X 10.9, iMac 27-inch 2.8 GHz i7, 8 GB RAM) the current snapshots.db file has now reached 2.12 GB and is still growing. No further help from apple so far - they apparently cannot reproduce the behavior.

It is possible to manually delete the file, which I did after my first one reached 1.76 GB. You can also replace it with an empty system immutable snapshots.db file, which prevents the system from writing to it, although you then get 'assertion failed' console messages every few minutes.

I have no real use for this file; 70-150 MB would be fine, but the disk space it consumes on my system is unacceptable.

I recommend you file a bug report with apple as well.

  • I’m going to do the same and delete the file to see how large the filesize it’ll reproduce. Hopefully the the reproduced file will be around 250 MB since I’ve been upgrading instead of clean install since Lion. – sayzlim Nov 30 '13 at 9:28
  • 1
    If you want to ask a follow on question on how to dump or summarize the contents of the file, it might help you, @sayzlim and others with folders > 1 GB know what is being stored. – bmike Nov 30 '13 at 10:45
3

Alternatively, you could disable the launchdaemon that spawns these snapshots and writes to that file. I did this on my rMBP running Mavericks since the console was flooded with "powerstats" logs. After I ran the following command, both the console log reports and the growth of the file you refer to ceased.

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.systemstats.daily.plist 
3

The systemstatsd daemon collect a selection of system statistics about system power usage and it usually runs unnoticed in the background. So generally, there’s nothing to concern.

If the database file gets too big (snapshots.db), it can be emptied when you stop/unload the service as per this post:

sudo launchctl stop com.apple.systemstatsd
sudo launchctl stop com.apple.systemstatsd.analysis

then flush the file by:

sudo sh -c ">/private/var/db/systemstats/snapshots.db"
2

I can confirm that running

sudo sqlite3 /private/var/db/systemstats/snapshots.db "vacuum;"

will compress the database down. Mine went from 530MB to 74MB, conforming other postings here. Thus, garbage collection or write damage on this database is probably a culprit. I would venture that the more probable assumption is on a bad write, as my CCC could not write it over (nor could I copy it to another directory)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .