diff options
Diffstat (limited to 'src/org/traccar/Main.java')
-rw-r--r-- | src/org/traccar/Main.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 1b8d93e34..baad9d040 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -17,9 +17,14 @@ package org.traccar; import org.traccar.helper.Log; +import java.sql.SQLException; +import java.util.Timer; +import java.util.TimerTask; import java.util.Locale; public final class Main { + static final long cleanDelay = 10*1000; + static final long cleanPeriod = 24*60*60*1000; private Main() { } @@ -35,6 +40,18 @@ public final class Main { Context.getWebServer().start(); } + Timer timer = new Timer(); + timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + try { + Context.getDataManager().clearPositionsHistory(); + } catch (SQLException error) { + Log.warning(error); + } + } + }, cleanDelay, cleanPeriod); + Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { |