Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Need cron expression to run job on 1pm,6pm and 11pm

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the below cron expression to execute the spring job. But it is not working.

0 0 13,18,23 * * ?

Please help me on it.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really a Spring question.. Moving to Linux forum
 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interestingly, Quartz Scheduler also uses such cron triggers. I'm not sure if that is what you are referring to also or if you are referring to some other framework's triggers. If it is Quartz Scheduler you're referring to, then you might find this page quite helpful.
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if that link doesn't help, then try this link: ItDoesntWorkIsUseless and then post a follow-up based on that.
 
author
Posts: 23843
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

krishna bala wrote:I am using the below cron expression to execute the spring job. But it is not working.

0 0 13,18,23 * * ?



I think you set the wrong fields -- that looks like a crontab line for running a job at midnight on the 13th, 18th, and 23rd, day of the month.

Henry
 
krishna bala
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply.

0 17,18,19 * * * ? , will it work?

 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think you set the wrong fields -- that looks like a crontab line for running a job at midnight on the 13th, 18th, and 23rd, day of the month.


Careful now. Spring scheduler expressions look like cron expressions, and they serve the same purpose, but their syntax is different in a very confusing (stupid, IMO) way. Specifically, the columns do not have the same meaning.

Cron (https://en.wikipedia.org/wiki/Cron#Format) :

minute hour dayOfMonth month dayOfWeek



Spring scheduler (http://javahunter.wordpress.com/2011/05/05/cronscheduler-in-spring/) :

Seconds Minutes Hours DayOfMonth Month DayOfWeek Year

 
Henry Wong
author
Posts: 23843
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

I think you set the wrong fields -- that looks like a crontab line for running a job at midnight on the 13th, 18th, and 23rd, day of the month.


Careful now. Spring scheduler expressions look like cron expressions, and they serve the same purpose, but their syntax is different in a very confusing (stupid, IMO) way. Specifically, the columns do not have the same meaning.



Just as an FYI, I entered this conversation via the Linux forum -- so, I am definitely not answering this in regards to Spring.

Henry
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The expression in Krishna's first post looks OK to me - so he needs to tell us what actually happened, like Paul said. When does this expression fire (which I assume he has tested by now)?
 
krishna bala
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for your reply.
I will expalin my exact requirement here.

I am using spring Quartz to run my job.

job should trigger at 1pm,6pm and 11pm.

Can any one provide cron expression for it?

I am using following expression to run my job. but job is not triggering.

<bean id="sampleTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="sampleTransactions"/>
<property name="cronExpression" value="0 0 13,18,23 * * ?"/>
</bean>

quick reposne will appriciate , thanks in advance
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it doesn't trigger at the times you desire, when does it trigger? You should be logging the times so that you can look it up later. If it doesn't trigger at all, maybe there's something else wrong with your Spring config.
 
krishna bala
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
it is workign fine in linux not in windows.
it might be due to timeformat issue. In my linux server time format is 24hh , in windows it s 12hh

Thanks a lot.
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting. Does it trigger correctly for times before noon?
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a side note, on my Windows, the cron expression for that one is

"0 0 13,18,23 ? * MON,TUE,WED,THU,FRI,SAT,SUN".

I'm using Quartz Scheduler library 2.1.x.

I think "0 0 13,18,23 ? * *" should also work.



 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!