Win a copy of Microservices Testing (Live Project) this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

cron expression

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, can someone help me verify whether my cron expressions are correct or not?

To run everyday at 1AM:

0 0 1 ? * *



to run at 1am at first day of each month:

0 0 1 1 * ?

 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Version of cron only has 5 fields:

I don't understand your question-mark.
[ August 17, 2006: Message edited by: Stefan Wagner ]
 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the extra field is the first one actually because I got specify the seconds too

actually it's a cron expression inside a quartz scheduler....
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a snippet for cron syntax from the man page
---

SunOS 5.9 Last change: 19 Apr 2002 1

User Commands crontab(1)

integer patterns that specify the following:

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 of these patterns may be either an asterisk (meaning
all legal values) or a list of elements separated by commas.
An element is either a number or two numbers separated by a
minus sign (meaning an inclusive range). Notice that the
specification of days may be made by two fields (day of the
month and day of the week). Both are adhered to if specified
as a list of elements. See EXAMPLES.

The sixth field of a line in a crontab file is a string that
is executed by the shell at the specified times. A percent
character in this field (unless escaped by \) is translated
to a NEWLINE character.

Only the first line (up to a `%' or end of line) of the com-
mand field is executed by the shell. Other lines are made
available to the command as standard input. Any blank line
or line beginning with a `#' is a comment and will be
ignored.

EXAMPLES
Example 1: Cleaning up core files

This example cleans up core files every weekday morning at
3:15 am:

15 3 * * 1-5 find $HOME -name core 2>/dev/null | xargs rm -f

Example 2: Mailing a birthday greeting

0 12 14 2 * mailx john%Happy Birthday!%Time for lunch.

Example 3: Specifying days of the month and week

This example

0 0 1,15 * 1

would run a command on the first and fifteenth of each
month, as well as on every Monday.

To specify days by only one field, the other field should be
set to *. For example:

0 0 * * 1

would run a command only on Mondays.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic