• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root velocity init d question or timing question

dcooterfrog

Well-Known Member
a couiple of questions
I have a sqlite3 script I would like to run at least at each reboot but preferable on a schedule.

does busibox suport cron
how do I run the script from a shell script for init d

in terminal or abd I
cd to the directory where the db is
then I type

sqlite database.db
.read sqlscript.sql
.end
 
If you want it on a schedule... use cron


Code:
BusyBox v1.18.4darkXshadows (2011-04-28 23:05:11 CDT) multi-call binary.

Usage: crontab [-c DIR] [-u USER] [-ler]|[FILE]

	-c	Crontab directory
	-u	User
	-l	List crontab
	-e	Edit crontab
	-r	Delete crontab
	FILE	Replace crontab by FILE ('-': stdin)


I haven't even considered using crond on android, and I was a little surprised to see it there. but it is there. I use it on all my tux machines to automate updates, repo syncing, and other things. Im not sure how to get it going on android, and after spending about 25 seconds playing with it you will need some additional configuration (it just bitches at me saying it doesnt know who uid0 {root} is) But see what you can do and let me know. when I have time I may look into it. (also check market there are prolly apps that emulate what crond does)


Or you can put your commands in a script
Code:
#!/system/bin/sh
db="/path/to/your/db/file"
sqlscript="/path/to/your/sqlscript.sql

#open db and read the script
sqlite3 -init $sqlscript $db 
exit 1
#exit the sqlite shell (think this will be enough)

#Also note the sdcard is not mounted during init, so you may want to put
#your stuff in like /etc/velocity/ or wherever on either system or data
Name it like 06sqlitedbreader (or whatever the # is the execution order, do a ls /etc/init.d to see the other inits)
chmod it 777
and it will run at boot.

To test the script
run it manually in a terminal by invoking it
sh /etc/init.d/06sqlitedbreader



good luck im runnin out the door or I would explain more

EDIT fixed script after reading sqlite3 --help

Code:
bash-3.2# sqlite3 --help
Usage: sqlite3 [OPTIONS] FILENAME [SQL]
FILENAME is the name of an SQLite database. A new database is created
if the file does not previously exist.
OPTIONS include:
   -init filename       read/process named file
   -echo                print commands before execution
   -[no]header          turn headers on or off
   -bail                stop after hitting an error
   -interactive         force interactive I/O
   -batch               force batch I/O
   -column              set output mode to 'column'
   -csv                 set output mode to 'csv'
   -html                set output mode to HTML
   -line                set output mode to 'line'
   -list                set output mode to 'list'
   -separator 'x'       set output field separator (|)
   -nullvalue 'text'    set text string for NULL values
   -version             show SQLite version
 
Back
Top