Daily Total Distance

Ron Volpe5 years ago

Hi there,

I am new to Traccar, I have to day I really like it!

I am trying to get a chart of daily total distance. So each day starts with 0 kms. Is that possible?

Also, is it possible to include a legend? I cant see which line is which tracker device right now.

Thanks a lot,

Roland

Michał Piasecki5 years ago

It's probably not the most optimal way to do it, but consider doing this:

  1. Write a scheduled event for MySQL that would set the distance traveled of your device to 0 every midnight
  2. Since Traccar won't realize something changed in DB, create a cron job (or Windows equivalent) that would restart the Traccar daemon every midnight (probably like 2 minutes after, just to be sure)

As for the legend - I'm not sure if that's what you mean, since I never tested it - I think you can change report color of a device in its attributes.

Michał Piasecki5 years ago

To expand on the above a bit:

  1. You can follow this guide https://www.dbrnd.com/2016/11/mysql-how-to-create-a-sql-job-or-event-scheduler-for-scheduling-the-database-task-to-execute-automatically/. After DO, just paste this: DELETE FROM tc_positions,tc_events WHERE deviceid = xxx;, where xxx is your device ID. Keep in mind that it's the database internal ID, you can see what ID you need in tc_devices. The whole thing is way easier if you use something like phpmyadmin.
  2. A basic cron job on a systemd based distribution would look like this: 0 0 * * * systemctl restart traccar. Just put it in root's crontab, using sudo crontab -e. For specific instructions just use google, shouldn't be too complicated.
Ron Volpe5 years ago

Thanks, I'll give it a go!

Slawek5 years ago

delete from tc_position where deviceid = xxx clear all history