mercredi 29 avril 2015

Amazon EC2 - Quartz and Job not running at correct time

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




Aucun commentaire:

Enregistrer un commentaire