history delete

Vani3 years ago
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.

i receive this message ?

Anton Tananaev3 years ago

And?

Vani3 years ago

how can i use this code:

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

i receive

mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
Anton Tananaev3 years ago

I don't understand the problem. You run the code. Those warnings are expected. What is the issue exactly?

Hi Anton i am also facing this same issue, I agree that this warning message is as expected but it is not clearing db as well and there is no error message displayed apart from this.

i have apporx 1000 devices and it is using 250GB diskspace and MySQL size is 174GB /var/lib/mysql

I tried to follow all instructions as mentioned on traccar clear history page.

Please guide what can be wrong with it

Anton Tananaev9 days ago

What makes you think it's not clearing the database?

There are few things which made me think it is not clearing db

  1. MySQL size is 174GB is still 174GB after running queries
  2. Traccar db Size which is part of (174GB) is 64GB so i think even if it is clearing the db it is not freeing up the space on the server.
  3. I am having approx 1000 devices and as per many comments it should not use this much space if it is clearing.

So i think there is something wrong i am doing

Anton Tananaev9 days ago

Deleting records won't free up disk space.

Mysql is locally hosted on digital ocean and i need to upgrade storage in every few weeks and it is endless.

What do you mean by deleting records wont free up space? Then how should i free up space?

Anton Tananaev9 days ago

Deleting will free space inside the database file, but you won't see the actual file shrink. That won't happen.