Search code examples
spring-batchexit-code

CommandLineJobRunner exit status on command stop


I'm working on SpringBatch using .bat and .sh. When I use the -stop flag, I'm thought I should wait for a non zero exit code if the job doesn't exist or isn't running. In reality, I get 0 if the job ended without error.

Where am I wrong?


Solution

  • When using the CommandLineJobRunner to stop a job, what you're really doing is making a request to stop a job. The CommandLineJobRunner returns once the request is made, not once the job stops because that could be an indeterminate amount of time. The only way you'd get a non-zero return code using the CommandLineJobRunner to stop a job is if the job isn't running (or can't be found in the JobRepository).