title: How to trigger the Spring Boot CRON job automatically when tomcat is up and running?
body: <p>I have created CRON job using spring boot process and this job will repeat the execution for every 1 hour. From eclipse, it is working fine. Now, Spring Boot application (CRON Job) has exported as war file and put it in tomcat with default port 8080.</p>
  
  <p>Tomcat has started successfully and running, but CRON job is not started.<br>
  <strong>Application.java</strong></p>
  
  <pre><code>package com.task;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  import org.springframework.boot.builder.SpringApplicationBuilder;
  import org.springframework.scheduling.annotation.EnableScheduling;
  import org.springframework.boot.web.support.SpringBootServletInitializer;
  
  @SpringBootApplication
  @EnableScheduling
  @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})ppublic class Application extends SpringBootServletInitializer {
  
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
          return application.sources(Application.class);
      }
  
      public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
    }
  }
  </code></pre>
  
  <p><strong>Jar Execution File</strong></p>
  
  <pre><code>@Override
      public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
  
          String gitPath = null;
          String rallyPath = null;
          String chefPath = null;
          String jenkinsPath = null;
          try {
  
              // Data Pull from jenkins
              jenkinsPath = PropertyManager.getProperty("Jenkins_FILE_PATH", "application.properties");
               Process p = Runtime.getRuntime().exec("cmd.exe /c start java -jar " + jenkinsPath  + " cmd");
  
  
          } catch (Exception e2) {
              // TODO Auto-generated catch block
              e2.printStackTrace();
          } 
  
  
          return RepeatStatus.FINISHED;
      }
  </code></pre>
  
  <p>I have added the below dependency in <strong>pom.xml</strong>  </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.task&lt;/groupId&gt;
      &lt;artifactId&gt;springboot-batchtask&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;SpringBatch&lt;/name&gt;
      &lt;description&gt;Spring Batch-Spring Boot&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.4.3.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;start-class&gt;com.task.Application&lt;/start-class&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-batch&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  
  &lt;/project&gt;
  </code></pre>
  
  <p>How to trigger the Spring Boot CRON job automatically when tomcat is up and running?</p>