I have a java app deployed on an Amazon EC2 server. I use quartz for scheduling various jobs.
I tried scheduling a job to run at 9am - I noticed it didnt execute until 10am I then tried to execute a job at 9am GMT-5 -should of executed at 2pm GMT but it actually executed at 3pm GMT
On further analysis i noticed the time on my Amazon server was set in UTC and is an hour behind GMT currently
I was just wondering - what part of my setup is not currently correct since the jobs are not executing at the correct time?
Do I need to specify anything when setting the cron trigger? I am setting up the Cron in quartz as follows using the CronScheduleBuilder
CronExpression cronExpression = new CronExpression(cronValue);
TimeZone timeZone = TimeZone.getTimeZone("Etc/GMT-5");
cronExpression.setTimeZone(timeZone);
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(triggerName).startNow()
.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
JobDetail job = JobBuilder.newJob(MyCloudTasksServerTaskExecutor.class).withIdentity(taskId.toString())
.storeDurably(true).build();
Any help is greatly appreciated
As you wrote the EC2 server is running with UTC. GMT changed at the last Sunday of March from standard time to daylight saving time.
I would suggest to time all your jobs in UTC. Then the start time of the job is different in summer and winter. You have to decide if this is OK for you.
Else you have to create two timers, one running from March to October and the other from October to March which differ in one hour.
It is also logical that the EC2 instances run with UTC because then a shift across time zones is easier to achieve.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments