0

I use

 CommandLineJobRunnerWrapper

as main class. For run job use

SimpleJobLauncher

for execute job one time. How I could schedule it to execute e.g. each day at 10 o'clock? Because now application immedeately exit after method execute finished. I have tried use spring scheduler but without success.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user710818
  • 23,228
  • 58
  • 149
  • 207
  • you can use spring task scheduler to schedule the jobs , it use the @schedule for any method with cron expression . – RSCode Nov 05 '14 at 17:31

1 Answers1

1

You could just use the Scheduled annotation

@Scheduled(cron="0 0 10 * * MON-FRI")

on your method.

flob
  • 3,760
  • 2
  • 34
  • 57
  • yes, I have used but application don't remain up. It exits. – user710818 Nov 05 '14 at 17:29
  • You will have to keep your application running ;-) Like `while(true){Thread.sleep(10000);}` after you initialized Spring or do something else to daemonize your application - see http://stackoverflow.com/q/534648/510711 for example. – flob Nov 05 '14 at 17:34
  • Are you sure with that cron expression? Shouldn't it be `0 0 10 * * MON-FRI` (or `0 0 10 * * ?`)? – Tom Nov 05 '14 at 17:36