knowledgeC.db and Screen Time on Mac, explained
Updated
knowledgeC.db is a SQLite database where macOS records activity such as which app was in use and when. The per-user copy is at ~/Library/Application Support/Knowledge/knowledgeC.db, and it's one of the sources behind Screen Time. You can read it with the built-in sqlite3 tool once Terminal has Full Disk Access, ideally on a copy. It is undocumented, covers only about the same four weeks as the Screen Time report, and on recent macOS versions much usage data has moved to a newer store called Biome.
Where it is and what's inside
The file sits in your user Library, next to companion files ending in -wal and -shm that hold recent writes. The main table is ZOBJECT. Each row is an event with a start and end time and a "stream" name that says what kind of event it is. The ones relevant to Screen Time:
/app/usage: which app was in the foreground, withZVALUESTRINGholding the bundle identifier (for examplecom.apple.Safari)./app/webUsage: website time recorded for browsers.
ZSTARTDATE and ZENDDATE are in Mac absolute time: seconds since January 1, 2001. Add 978307200 to get Unix time. The ZSOURCE column points to the ZSOURCE table, which includes a device identifier, so rows synced from other devices can be told apart.
There is also a system-wide copy under /private/var/db/CoreDuet/Knowledge/, which is protected more strictly. For your own usage, the one in your Library is the one to look at.
How to read it safely
- Open Apple menu > System Settings > Privacy & Security > Full Disk Access and turn it on for Terminal. Quit and reopen Terminal.
- Copy the database and its companion files to a folder of your own:
mkdir -p ~/kc && cp ~/Library/Application\ Support/Knowledge/knowledgeC.db* ~/kc/ - Open the copy:
sqlite3 ~/kc/knowledgeC.db - List the streams your Mac records:
SELECT ZSTREAMNAME, COUNT(*) FROM ZOBJECT GROUP BY ZSTREAMNAME; - Check the date range:
SELECT datetime(MIN(ZSTARTDATE) + 978307200, 'unixepoch', 'localtime'), datetime(MAX(ZSTARTDATE) + 978307200, 'unixepoch', 'localtime') FROM ZOBJECT WHERE ZSTREAMNAME = '/app/usage'; - Type
.quitwhen you're done, and switch Full Disk Access for Terminal off if you no longer need it.
Why copy first: the live file is in use by the system. Reading a copy can't interfere with it, and you won't accidentally change anything. Copy the -wal file too, or the most recent records may be missing.
For a ready-made per-app, per-day query that writes a spreadsheet file, see Screen Time CSV export.
Limits to keep in mind
- Same short window. Records are pruned on roughly the same schedule as Screen Time, about four weeks. The database is not a hidden long-term archive, and deleted days can't be recovered from it.
- Biome. Since macOS 13 and iOS 16, Apple records much usage data in Biome, under
~/Library/Biome, in an undocumented format. Depending on your version,knowledgeC.dbmay hold less than the Screen Time report shows, or some streams may be empty. - Undocumented and changing. Apple can change table and stream names in any update. A query that works today may return nothing after an update.
- Totals won't always match. Screen Time applies its own rules to overlapping and very short sessions, so your sums can differ from Apple's report.
- iPhone data. iPhone usage only reaches the Mac when Share Across Devices is on, and where it's stored depends on the macOS version.
Common questions
Can I open knowledgeC.db without Full Disk Access?
No. macOS protects the Knowledge folder, so Terminal (or any app) gets "Operation not permitted" until it has Full Disk Access. That's the only way macOS allows reading Screen Time data.
Does knowledgeC.db have older Screen Time data than System Settings?
In practice, no. It's cleaned on about the same schedule, so you'll usually see a few weeks, not months.
Is there a knowledgeC.db on iPhone?
iOS has similar databases, but they aren't accessible on a normal iPhone. Apps and users can't open them, so the Mac is the practical place to read this data.
Can I delete or edit it?
Don't. Editing system databases can break Screen Time or other features, and there's nothing to gain. Work on copies only.
Where Screen Time History helps
Screen Time History is a Mac app that reads Screen Time data with Full Disk Access, so you don't have to write queries or follow format changes yourself. It keeps every day from the day it's installed, including the iPhone when Share Across Devices is on, and can't bring back days the system already removed.