title: Quartz scheduler shuts down before job execution
body: <p>New to quartz scheduler. What I am trying to achieve is to fire one trigger in the future and then shutdown the scheduler. I am using <code>scheduler.shutdown(true)</code> for this, but it shuts down before executing the job. I have to call shutdown() as I am going to implement the scheduler in a web app.</p>
  
  <p><strong>So how do I shutdown scheduler after job executes ?</strong></p>
  
  <p><strong>JOB:</strong></p>
  
  <pre><code>public class HelloJob implements Job {
  
      public HelloJob(){
      }
  
      public void execute(JobExecutionContext context)
              throws JobExecutionException {
                  System.out.println("Hello Quartz on " + new Date());    
              }
  }
  </code></pre>
  
  <p><strong>Scheduler:</strong></p>
  
  <pre><code>public class QuartzTest {
  
      public void scheduleLoad(String time) {
          try {
              // Transform user input into a date
              SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy:HH:mm:ss");
              Date scheduleDate = dateFormat.parse(time);
  
              // Print Current vs. Scheduled time/date
              System.out.println("Current time - " + new Date());
              System.out.println("Scheduled time - " + scheduleDate); 
  
              // Grab the Scheduler instance from the Factory 
              Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
  
              // and start it off
              scheduler.start();
  
              // Define a job and tie it to a class
              JobDetail job = newJob(HelloJob.class)
                      .withIdentity("job1", "group1")
                      .build();
  
              // Trigger job to run now and repeat every 10 secs
              SimpleTrigger trigger = (SimpleTrigger) newTrigger()
                      .withIdentity("trigger1", "group1")
                      .startAt(scheduleDate)
                      .forJob("job1","group1")
                      .build();
  
              // Schedule job using trigger
              scheduler.scheduleJob(job, trigger);
  
              // Shutdown the scheduler after job is executed
              scheduler.shutdown(true);
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      public static void main(String[] args) {
          String runTime = "04/10/2013:20:07:00";
          QuartzTest quartz = new QuartzTest();
          quartz.scheduleLoad(runTime);
      }
  }
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>Current time - Wed Apr 10 20:06:31 IST 2013
  Scheduled time - Wed Apr 10 20:07:00 IST 2013
  [main] INFO org.quartz.impl.StdSchedulerFactory - Using default implementation for ThreadExecutor
  [main] INFO org.quartz.simpl.SimpleThreadPool - Job execution threads will use class loader of thread: main
  [main] INFO org.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
  [main] INFO org.quartz.core.QuartzScheduler - Quartz Scheduler v.2.1.7 created.
  [main] INFO org.quartz.simpl.RAMJobStore - RAMJobStore initialized.
  [main] INFO org.quartz.core.QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.1.7) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED'
    Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
    NOT STARTED.
    Currently in standby mode.
    Number of jobs executed: 0
    Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
    Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
  
  [main] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
  [main] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler version: 2.1.7
  [main] INFO org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
  [main] INFO org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutting down.
  [main] INFO org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED paused.
  [main] INFO org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutdown complete.
  </code></pre>
  
  <p><strong>quartz.properties:</strong></p>
  
  <pre><code>org.quartz.scheduler.instanceName = MyScheduler
  org.quartz.threadPool.threadCount = 3
  org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
  org.quartz.scheduler.skipUpdateCheck: true
  </code></pre>