Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cron expression

 
vivien siu
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • 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 * ?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • 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
  • 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....
 
Jay Suttiruttana
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic