AnthonyMusgrove / Emby-ScripterX

Run custom external application or script (batch/bash/powershell/php/python/node.js/custom) on various events within the Emby Server.
https://emby-scripterx.com
76 stars 6 forks source link

How to run sqlite commands #48

Closed bakes82 closed 3 years ago

bakes82 commented 3 years ago

Can this plugin run these commands to optimize the sqllite db?

/var/packages/EmbyServer/target/sqlite/bin/sqlite3 library.db "VACUUM" /var/packages/EmbyServer/target/sqlite/bin/sqlite3 library.db "ANALYZE" /var/packages/EmbyServer/target/sqlite/bin/sqlite3 library.db "REINDEX"

Linusten commented 3 years ago

I have created a batch file, works like a charm on windows to purge the activity log:

REM Parameters expected: None cd C:\Users\Administrator\AppData\Roaming\Emby-Server\programdata\data sqlite3.exe "activitylog.db" "DELETE FROM ActivityLog;" "VACUUM;" ".exit" @echo Scheduled Task Run. >> C:\scheduledtask.log

bakes82 commented 3 years ago

Would need the linux versions :P

Linusten commented 3 years ago

Just assumes not tested: Install the Sqlite cli binary --> https://sqlite.org/cli.html

create a shell script named like "optimize.sh":

!/bin/sh

sqlite3 /path/to/db/foo.db 'VACUUM;' sqlite3 /path/to/db/foo.db 'ANALYZE;' sqlite3 /path/to/db/foo.db 'REINDEX;'

now make it executable: chmod u+x optimize.sh

AnthonyMusgrove commented 3 years ago

Thank you so much guys for sorting this one out!

Kindest regards, Anthony