title: start the job immediately using quartz framework?
body: <p>I am running some jobs periodically using <code>quartz framework</code>. I have a below <code>quartz_config</code> xml file which contains all the jobs I am running and at what interval.</p>
  
  <pre><code>&lt;job-scheduling-data
      xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_2_0.xsd"
      version="1.8"&gt;
  
      &lt;schedule&gt;
          &lt;job&gt;
              &lt;name&gt;ParserApp&lt;/name&gt;
              &lt;job-class&gt;com.process.task.ParserApp&lt;/job-class&gt;
          &lt;/job&gt;
          &lt;trigger&gt;
              &lt;cron&gt;
                  &lt;name&gt;ParserApp&lt;/name&gt;
                  &lt;job-name&gt;ParserApp&lt;/job-name&gt;
                  &lt;cron-expression&gt;0 0 0/3 1/1 * ? *&lt;/cron-expression&gt;
              &lt;/cron&gt;
          &lt;/trigger&gt;
      &lt;/schedule&gt;
  
  &lt;/job-scheduling-data&gt;
  </code></pre>
  
  <p>I am running <code>ParserApp</code> job every 3 hours. Now what I have noticed is - whenever I start my application, it doesn't start <code>ParserApp</code> job immediately. What it does instead is, it starts <code>ParserApp</code> jobs after 3 hours only which is fine as per cron expression. Is there any way by which I can start <code>ParserApp</code> job immediately whenever application is started up and then next run should happened after 3 hours only just like java <code>ScheduledExecutorService</code> does?</p>
  
  <p>In the below code, as soon as you start <code>executorService</code>, it will call <code>parserApp</code> immediately and then it will call <code>parserApp</code> again after 3 hours periodically. Is there any way to do the same thing using <code>quartz-scheduler</code>?</p>
  
  <pre><code>executorService.scheduleAtFixedRate(new Runnable() {
    @Override
    public void run() {
      parserApp();
    }
  }, 0, 3, TimeUnit.HOURS);
  </code></pre>
  
  <p>Below is how I am starting all the jobs using quartz scheduler:</p>
  
  <pre><code>StdSchedulerFactory factory = new StdSchedulerFactory();
  try {
    factory.initialize(App.class.getClassLoader().getResourceAsStream("quartz.properties"));
    Scheduler scheduler = factory.getScheduler();
    // starts all our jobs using quartz_config.xml file
    scheduler.start();
  } catch (SchedulerException ex) {
    logger.logError("error while starting scheduler= ", ExceptionUtils.getStackTrace(ex));
  }
  </code></pre>