This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java Cron Jobs Stop for one hour a day. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Cron Jobs Stop for one hour a day." Watch "Java Cron Jobs Stop for one hour a day." New topic
Author

Java Cron Jobs Stop for one hour a day.

pradeep gamage
Ranch Hand

Joined: Aug 03, 2009
Posts: 85

I am developing java application and in this i wanted to run some method periodically. I have used java schedule to run that method periodically. This is my Cron Expression.

.
This works fine. Now I wanted to stop running this scheduler for one hour per day. How I can write Cron Expression to do it? Give me a idea.

Thanks in advance


Software Engineer(BSC):SCJP 1.5
(Knowledge is power when applied)
RatiKanta pal
Ranch Hand

Joined: Nov 13, 2011
Posts: 62

Hi Pradeep,
Could you please be more clear on whcih hour or any hour can do??

If thats the case(Any hour) you can write the trigger as "0 * 0-22 ? * *" which will trigger every day from 0 to 22th hour and will stop working for the 23rd hour.

pradeep gamage
Ranch Hand

Joined: Aug 03, 2009
Posts: 85

I have done it like this way .
.
Its seem work fine.

Thanks for answer...
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

I would even say that is the CORRECT way to do it. It is obvious what is intended - that you don't want it to run from 1p - 2p

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java Cron Jobs Stop for one hour a day.
 
Similar Threads
scheduling java program in unix evironment
Taking Memory Usage Periodically
Cron expression issue
automated mailing functionality
Setting Cron Expression in EJB