aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/Main.java')
-rw-r--r--src/org/traccar/Main.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java
index 1b8d93e34..0070904ab 100644
--- a/src/org/traccar/Main.java
+++ b/src/org/traccar/Main.java
@@ -16,10 +16,13 @@
package org.traccar;
import org.traccar.helper.Log;
-
+import java.util.Timer;
+import java.util.TimerTask;
import java.util.Locale;
public final class Main {
+ static final long cleanDelay = 10*1000; //10 sec
+ static final long cleanPeriod = 24*60*60*1000; //24 hr
private Main() {
}
@@ -35,6 +38,19 @@ public final class Main {
Context.getWebServer().start();
}
+ Timer timer = new Timer();
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ // Clean positions history
+ try {
+ Context.getDataManager().clearPositionsHistory();
+ } catch (Exception error) {
+ Log.warning(error);
+ }
+ }
+ }, cleanDelay, cleanPeriod);
+
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {