Update 34 files

- /nfc/README.md
- /nfc/clean_old_logs.sh
- /nfc/clockin.py
- /nfc/emptycards.py
- /nfc/sync_clocks.sh
- /piservices/Dockerfile
- /piservices/Portainer-lamp-stack.env
- /piservices/Portainer-lamp-stack.yaml
- /piservices/README.md
- /piservices/avahi-alias.service
- /piservices/clockpy.service
- /piservices/emptycards.service
- /piservices/nfc-sync.service
- /piservices/test.sh
- /www/404
- /www/get-table-data.php
- /www/habiwan copy.png
- /www/habiwan.png
- /www/index.php
- /www/log_swipe.php
- /www/manage_data.php
- /www/manifest.json
- /www/names.csv
- /www/network_audit.csv
- /www/network-tracker.html
- /www/nfc_debug.log
- /www/scanner.html
- /www/staff_names.php
- /www/times.csv
- /www/check_update.php
- /www/dev.php
- /www/favicon.png
- /www/JsBarcode.all.min.js
- /www/README.md
This commit is contained in:
jpd committed 2026-07-24 14:37:45 +01:00
1 parent 10824ab851
commit a201d5d7ac
34 files changed
+9453

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# added sudo crontab to the pi to trim old data at 2 am:
# 0 2 * * * /bin/bash /home/YOURPIUSER/nfc/clean_old_logs.sh >/dev/null 2>&1
TIMES_FILE="/home/YOURPIUSER/nfc/times.csv"
# 1. Get the date 6 months ago (for testing)
LOG_CUTOFF=$(date -d "6 months ago" +%Y-%m-%d)
# 2. Filter using universally compatible literal matching
awk -v cutoff="$LOG_CUTOFF" '
{
if (match($0, /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/)) {
date_part = substr($0, RSTART, RLENGTH)
if (date_part < cutoff) {
next
}
}
print $0
}' "$TIMES_FILE" > "${TIMES_FILE}.tmp"
# 3. Safely replace the file
mv "${TIMES_FILE}.tmp" "$TIMES_FILE"
# 4. Force the sync script to grab the new file inode
systemctl restart nfc-sync.service