Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i want call my method every one hour except 12 am (Using cron job )

 
ayyappan Bas
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi All

i want invoke my method every one hour except 12 am .Currently i am using cron job .could you please any one help on this problem .the following expression will invoke my method on every one hour .

ex :
0 0 0/1 1/1 * ?
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Being a Java forum this seems a funny place to post this in but you should look at the man page

man 5 crontab

which describes the fields and explains how to set up a range of values. Hint - you need to two ranges on the hour field.
 
ayyappan Bas
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first five fields are:
minute (0-59)
hour (0-23)
day of the month(1-31)
month of the year (1-12)
day of the week (0-6 with 0 = Sunday)

Each field can be an asterisk meaning all values, or a single integer, several integers separated by commas, or two integers separated by a hypen to indicate a range.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey wrote:Hint - you need to two ranges on the hour field.

are you sure?

I assume 12 a.m. means midnight, not noon, but the term seems to be somewhat ambiguous.

If the OP means midnight, I think one range works. If they meant noon, then yes, two ranges.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:
Richard Tookey wrote:Hint - you need to two ranges on the hour field.

are you sure?

I assume 12 a.m. means midnight, not noon, but the term seems to be somewhat ambiguous.

If the OP means midnight, I think one range works. If they meant noon, then yes, two ranges.


I assumed that 12 a.m. was midday but of course if it is midnight then only one range is needed.

P.S. I did wonder if a single range between 13 and 11 would work; one day I might try it!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic