mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-07-21 09:02:45 +02:00
Modify cleanup.sh to use import_time_us for queries
Updated cleanup script to use import_time_us for deletions.
This commit is contained in:
@@ -483,11 +483,10 @@ Once changes are done you need to restart the script for changes to load.
|
|||||||
- Name it cleanup.sh
|
- Name it cleanup.sh
|
||||||
- Make it executable.
|
- Make it executable.
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
DB_FILE="/path/to/file/packets.db"
|
DB_FILE="/path/to/file/packets.db"
|
||||||
|
|
||||||
|
|
||||||
# Stop DB service
|
# Stop DB service
|
||||||
sudo systemctl stop meshview-db.service
|
sudo systemctl stop meshview-db.service
|
||||||
sudo systemctl stop meshview-web.service
|
sudo systemctl stop meshview-web.service
|
||||||
@@ -496,10 +495,22 @@ sleep 5
|
|||||||
echo "Run cleanup..."
|
echo "Run cleanup..."
|
||||||
# Run cleanup queries
|
# Run cleanup queries
|
||||||
sqlite3 "$DB_FILE" <<EOF
|
sqlite3 "$DB_FILE" <<EOF
|
||||||
DELETE FROM packet WHERE import_time < datetime('now', '-14 day');
|
DELETE FROM packet
|
||||||
DELETE FROM packet_seen WHERE import_time < datetime('now', '-14 day');
|
WHERE import_time_us IS NOT NULL
|
||||||
DELETE FROM traceroute WHERE import_time < datetime('now', '-14 day');
|
AND import_time_us < (strftime('%s','now','-14 days') * 1000000);
|
||||||
DELETE FROM node WHERE last_update < datetime('now', '-14 day') OR last_update IS NULL OR last_update = '';
|
SELECT 'packet deleted: ' || changes();
|
||||||
|
DELETE FROM packet_seen
|
||||||
|
WHERE import_time_us IS NOT NULL
|
||||||
|
AND import_time_us < (strftime('%s','now','-14 days') * 1000000);
|
||||||
|
SELECT 'packet_seen deleted: ' || changes();
|
||||||
|
DELETE FROM traceroute
|
||||||
|
WHERE import_time_us IS NOT NULL
|
||||||
|
AND import_time_us < (strftime('%s','now','-14 days') * 1000000);
|
||||||
|
SELECT 'traceroute deleted: ' || changes();
|
||||||
|
DELETE FROM node
|
||||||
|
WHERE last_seen_us IS NULL
|
||||||
|
OR last_seen_us < (strftime('%s','now','-14 days') * 1000000);
|
||||||
|
SELECT 'node deleted: ' || changes();
|
||||||
VACUUM;
|
VACUUM;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user