SQLite Forum

Can -wal -shm files be deleted if -wal file is empty?
Login
It makes no sense to be syncing the DB, wal and shm files unless they represent a snapshot in time of the file state for all three. And unless that is arranged, it makes little sense to be syncing the DB file alone when (obviously) that is done while the wal and shm files exist.

Dan's advice, applied to the three files where SQLite has created them, is sensible, safe and simple.  It is probably simpler than testing to see whether the wal file is empty and conditionally handling the results. That, together with not syncing the wal and shm files, (which could foul things up when the improperly synced copies are used, if they ever are), would be a complete, safe solution.

The smart solution would be to put an end to whatever sequence of events is routinely causing some application(s) using SQLite to either neglect closing all DB connections or be terminated before doing so.