After installing Mavericks, I discovered
snapshot.db (1.5 GB) file in:
What is the use of that file? Is it safe to delete it?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
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.
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.
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
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"
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)