naveen
naveen

Reputation: 159

Cron expression to schedule a task

I want to schedule a task from Jan 14th to July 12th every weekdays at 09.00 PM. Can someone help me in writing this cron expression.

Thanks,

Naveen.

Upvotes: 2

Views: 568

Answers (2)

Pritam Banerjee
Pritam Banerjee

Reputation: 18968

This is your answer :

0 0 21 1-14 1 MON-FRI 2015
0 0 21 ? 2-6 MON-FRI 2015
0 0 21 1-12 7 MON-FRI 2015

21 : fires at 9 pm

? : any day of the month

1-7 : January to July

MON-FRI : Weekdays

I don't think you can do it from January 12th to July 14th.

Upvotes: 0

Sam
Sam

Reputation: 27

You will have to add three entries in the crontab file for this scenario

00 21 14-31 1 1-5 /your/command/to/execute
00 21 * 2-6 1-5 /your/command/to/execute
00 21 1-12 7 1-5 /your/command/to/execute

Upvotes: 2

Related Questions