We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
I found out that Spring uses its own cron expression format. The thing is, I got an app where the user can input some cron expression to schedule a task so I'd like to take that cron expression and use with CronTrigger.
Is there any way to convert a normal cron expression into a Spring format?
while I am try to run the end part of spring boot application, it is continuously running. Please, tell me how to get proper solution for this problem. Because of that, i couldn't check my result.
Is there a way to specify a user to run this scheduled job? Like we setup a crontab for a user?
Hi, very good and helpful article!
Just a question, in the case of the fixed rate tasks, if you want to stop/interrupt the task, how would you do it?
Thanks.
Thank you!
While running in a Clustered environment, the scheduled task will run twice.
How can we make sure it is only run once.
Thanks, nice tip
disqus_NlDD94vXk9 ):
Hi, I have a scenario where it's pretty common to change the system date. I'm using @Scheduled with cron expression, it works fine before changing the date, but after changing the date, the scheduled method doesn't run, so I resolve to restarting the app every time a change in system date happens. Do you think the @Scheduled annotation uses a different date object from the system date?
how to get ThreadPoolTaskScheduler bean?
Please extend this article by adding scheduling task using using file watcher. Thanks
Last time I checked, SimpleDateFormat was not thread safe. You may want to create a new instance in each of the four methods and not as a static field.
DTAP GmbH You're right! Thanks for pointing this out. I think I'll change this to Java 8's DateTimeFormatter.
DateTimeFormatter is immutable and thread-safe.
That's an even better solution.
Hi, I have a problem when using @Schedule cron. Simple does not work. If I change to fixedRate for example works, but not using cron. I did the same way as you are showing.
I am using tomcat 7 running in a Mac for development. Do you have any idea what could be?
@Scheduled(cron = "*/10 * * * * *", zone = "Europe/Madrid")
Thank you
I tried the cron expression that you're using in my local system and it is working fine. Here are the logs -
2017-12-20 22:59:30.001 INFO 35254 --- [led-task-pool-1] c.example.schedulerdemo.ScheduledTasks : Cron Task :: Execution Time - 22:59:30
2017-12-20 22:59:40.001 INFO 35254 --- [led-task-pool-1] c.example.schedulerdemo.ScheduledTasks : Cron Task :: Execution Time - 22:59:40
I can't tell you why it's not working for you unless I see your code. It would be great if you can create a pull request with your code in the github repository.
show how to take it dynamically from applocation.proerties file