A full VACUUM rewrites the whole file and locks it while it runs. With incremental auto-vacuum, SQLite keeps enough bookkeeping to cut free pages off the end of the file whenever you ask.
The mode has to be set before the first table exists, or followed by one VACUUM to convert an existing file:
sqlite3 app.db "PRAGMA auto_vacuum = INCREMENTAL; VACUUM;"
sqlite3 app.db "PRAGMA auto_vacuum;"
2
After that, deleted rows still leave free pages behind, but you can release them on your own schedule:
sqlite3 app.db "PRAGMA incremental_vacuum(500);" > /dev/null
That frees up to 500 pages and shrinks the file by that much. Without a number it frees all of them. The shell prints an empty line per freed page, which is why the command sends the output to /dev/null. After a large delete, a file can lose half its size this way in a fraction of a second.
It is not a full replacement for VACUUM. It only moves pages around and does not repack half-empty pages or defragment anything, so the file can get more fragmented over time. The bookkeeping also costs a little extra work on every write. For a file that only grows, leave the setting at its default. I think it suits files with a lot of churn, like a cache or a queue table that empties every night.
Further reading: PRAGMA auto_vacuum, PRAGMA incremental_vacuum