Abdullah
Abdullah

Reputation: 3

Cron expression for every sept working day

How to create a cronexprrssion for ever 1st September working day. It means omit Sunday

Upvotes: 0

Views: 1662

Answers (2)

fedorqui
fedorqui

Reputation: 290025

Based on the format:

+---------------- minute (0 - 59)
|  +------------- hour (0 - 23)
|  |  +---------- day of month (1 - 31)
|  |  |  +------- month (1 - 12)
|  |  |  |  +---- day of week (0 - 6) (Sunday=0 or 7)
|  |  |  |  |
*  *  *  *  *  command to be executed

This should make it:

+---------------- at minute 0
|  +------------- at hour 0
|  |  +---------- at day 1
|  |  |  +------- at month 9 -> September
|  |  |  |  +---- at day 1 to 6, that is, all but Sunday
|  |  |  |  |
0  0  1  9 1-6 /your/path/ /your/script

Upvotes: 2

Cristian Sulea
Cristian Sulea

Reputation: 264

If you want what @Duncan said (a cron expression that finds the first working day in September), then this should do:

0 0 0 1W 9 ? *

Results:

  1. Tuesday, September 1, 2015
  2. Thursday, September 1, 2016
  3. Friday, September 1, 2017
  4. Monday, September 3, 2018
  5. Monday, September 2, 2019

Upvotes: 1

Related Questions