I'm encountering a very strange problem in my server when executing some jobs.
My code:
@WebListener
public class ReportingScheduler implements ServletContextListener {
private ScheduledExecutorService scheduler;
@Override
public void contextInitialized(ServletContextEvent event) {
scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(new ReportingJob(), 0, 10, TimeUnit.MINUTES);
}
@Override
public void contextDestroyed(ServletContextEvent event) {
scheduler.shutdownNow();
}
The method run() inside ReportingJob() is only printing.
You can see my schedule is supposed to run every 10 minutes.
I'm running this on tomcat. On my localhost, everything is all good. But in my server (Ubuntu 16.4) every time the job executes, execute earlier. I don't know why.
Some of my logs in ubuntu server:
2017-06-12 16:15:02 INFO ReportingJob:49 - START 10min JOB
2017-06-12 16:24:57 INFO ReportingJob:49 - START 10min JOB
2017-06-12 16:34:27 INFO ReportingJob:49 - START 10min JOB
2017-06-12 16:43:58 INFO ReportingJob:49 - START 10min JOB
On my localhost:
2017-06-12 16:15:02 INFO ReportingJob:49 - START 10min JOB
2017-06-12 16:25:02 INFO ReportingJob:49 - START 10min JOB
2017-06-12 16:35:02 INFO ReportingJob:49 - START 10min JOB
2017-06-12 16:45:02 INFO ReportingJob:49 - START 10min JOB
I already checked the server.xml config and it's the same.