diff options
Diffstat (limited to 'src/org/traccar/Main.java')
-rw-r--r-- | src/org/traccar/Main.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 1b8d93e34..e992691ad 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -17,10 +17,15 @@ 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 { + private static final long CLEAN_PERIOD = 24 * 60 * 60 * 1000; + private Main() { } @@ -35,6 +40,17 @@ public final class Main { Context.getWebServer().start(); } + new Timer().scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + try { + Context.getDataManager().clearPositionsHistory(); + } catch (SQLException error) { + Log.warning(error); + } + } + }, 0, CLEAN_PERIOD); + Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { |