logdb=`uci get weathermon.process.logdb`
-dumpdir=`uci get weathermon.process.archive_dir`/`echo "print(os.date(\"%Y/%m/%d\",os.time()-22*60*60))" | /usr/bin/lua`
+if [ -f "$logdb" ]; then
-mkdir -p $dumpdir
+ dumpdir=`uci get weathermon.process.archive_dir`/`echo "print(os.date(\"%Y/%m/%d\",os.time()-22*60*60))" | /usr/bin/lua`
-/usr/bin/weather-filter $logdb dump-compacted $yesterday $dumpdir
+ mkdir -p $dumpdir
-sqlite3 $logdb "delete from log where time_stamp<date('now','-1 day')"
+ /usr/bin/weather-filter $logdb dump-compacted $yesterday $dumpdir
+
+ sqlite3 $logdb "delete from log where time_stamp<date('now','-1 day')"
+
+fi