Which this script?
This script
cat > /etc/cron.daily/traccar-clear-database << EOF
#!/bin/bash
result=""
while [[ "$result" != *" 0 rows affected"* ]]; do
result=$(mysql -u root -proot traccar -vve "DELETE FROM tc_positions WHERE fixTime < DATE(DATE_ADD(NOW(), INTERVAL -7 DAY)) AND id NOT IN (SELECT positionId FROM tc_devices WHERE positionid IS NOT NULL) LIMIT 10000")
sleep 1
done
result=""
while [[ "$result" != *" 0 rows affected"* ]]; do
result=$(mysql -u root -proot traccar -vve "DELETE FROM tc_events WHERE eventTime < DATE(DATE_ADD(NOW(), INTERVAL -7 DAY)) LIMIT 10000")
sleep 1
done
EOF
chmod +x /etc/cron.daily/traccar-clear-database
As I see this is refering to local mySQL install. Is there something similar for remote database?
Yes, you should be able to use the same script. Just change mysql
command line arguments.
You mean with my public address and credentials?
Yes.
Hello.
I am using a remote mySQL database. In this case can I use this script for cleaning the history?
And if yes how would it be the syntax?