KItis
KItis

Reputation: 5646

what does this cronjob line mean

I have a cron expression, which is somewhat different from the expressions I have worked before, specially because of the ? operator( i don't know why it has been used)

following is the format that i have been refering to as the standard format. but the expression i have given after this standard format is not following this structure. could anybody help me to understand this new format. thanks in advance for any help.

* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

expression :

0  15 15 ? * 1-7

Upvotes: 2

Views: 2349

Answers (3)

KItis
KItis

Reputation: 5646

Ok guys, i found the solution, it is actually scheduling using java quartz scheduler.

this is how it get 6 parameters in the expression

my expression : 0 15 15 ? * 1-7

Seconds
Minutes
Hours
Day-of-Month
Month
Day-of-Week
Year (optional field)

The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify "no specific value". This is useful when you need to specify something in one of the two fields, but not the other. See the examples below (and CronTrigger JavaDoc) for clarification.

you can use this to verify your cron expressions http://www.cronmaker.com/

Upvotes: 2

Gilles Quénot
Gilles Quénot

Reputation: 185530

This is a mistake.

The format for the time in cron is in 5 columns. You have 6.

If I test your cronexpression :

0  15 15 ? * 1-7 ls

The crontab display :

crontab: installing new crontab
"/tmp/crontab.AzvS1Q":148: bad month
errors in crontab file, can't install.
Do you want to retry the same edit? 

Moreover, if I test with 5 columns with ? inside, I still get an error.

My cron implementation is cronie 1.4.8-3 on archlinux. I never seen ? in my old life in this context.

Upvotes: 3

Arran
Arran

Reputation: 25066

Besides the fact it seems it has too many characters, the question mark can be used in place of the * character for wildcard situations, for leaving the day-of-month blank or the day-of-week blank.

Upvotes: 1

Related Questions