/usr/bin/weather-filter $logdb dump-compacted $yesterday $dumpdir
- sqlite3 $logdb "delete from log where time_stamp<date('now','-1 day')"
+ sqlite3 $logdb "delete from log where time_stamp<date('now','-2 day')"
fi
if [ ! -z "$BACKLOGDB" ]; then
BACKLOG_BASE=$(basename "$BACKLOGDB")
- sqlite3 "$BACKLOGDB" ".backup $BACKUP_DIR/$BACKLOG_BASE"
+ sqlite3 -readonly "$BACKLOGDB" ".backup $BACKUP_DIR/$BACKLOG_BASE"
fi
if [ ! -z "$LOGDB" ]; then
LOG_BASE=$(basename "$LOGDB")
- sqlite3 "$LOGDB" ".backup $BACKUP_DIR/$LOG_BASE"
+ sqlite3 -readonly "$LOGDB" ".backup $BACKUP_DIR/$LOG_BASE"
fi
local dbdriver = require "luasql.sqlite3"
env = assert(dbdriver.sqlite3())
-con = assert(env:connect(logdb))
+con = assert(env:connect(logdb,'READONLY'))
if command == "list" then
now=`date +%s`
delta=$(( $now - $stamp ))
if [[ $delta -ge 300 ]]; then
+ logger weathermon restarting...
/etc/init.d/weathermon restart
fi
-pgrep weather-display > /dev/null || /etc/init.d/weather-display restart
+pgrep weather-lcd > /dev/null || /etc/init.d/lcd-weather restart
if code ~= 200 and backlog_con then
printLog("writing record to backlog...")
+ backlog_con:execute('BEGIN TRANSACTION')
backlog_con:execute(string.format("INSERT INTO queue(time_stamp,sensor_id,sensor,param,value) VALUES (datetime('now','localtime'),'%s','%s','%s',%f)",id,type,param,val))
+ backlog_con:execute('COMMIT')
end
end
if logdb then
+ log_con:execute('BEGIN TRANSACTION')
log_con:execute(string.format("INSERT INTO log(time_stamp,sensor_id,sensor,param,value) VALUES (datetime('now','localtime'),'%s','%s','%s',%f)",id,type,param,val))
+ log_con:execute('COMMIT')
end
end
io.close(f)
end)
end
-
end)
end