Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2269  / 1 Year ago, fri, december 9, 2022, 11:06:24

How do I define crontab date for second Wednesday (of every months) only? I would appreciate your help.


More From » cron

 Answers
3

You asked for cron so only using cron you can do this using bash's date as a 2nd test:


0   0  8-14 *   *   [ "$(date '+%u')" = "3" ] && {your script}


  • On every hour of days 8 through 14

  • and then check for wednesday with bash's date. Daynumber 3 is wednesday


The comment from Soren A is a little wrong (BUT the man page is also wrong). 0 0 8-14 * WED = “At 00:00 on every day-of-month from 8 through 14 and on Wednesday.” From the last link:



Tip 1: If the day-of-month or day-of-week part starts with a *, they form an intersection. Otherwise they form a union. * * 3 * 1 runs on the 3rd day of the month and on Monday (union), whereas * * */2 * 1 runs on every second day of the month only if it's also a Monday (intersection). The manpage is incorrect about this detail. More info.



[#1228] Friday, December 9, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
igeonlothe

Total Points: 370
Total Questions: 121
Total Answers: 114

Location: United States Minor Outlying Island
Member since Fri, Feb 5, 2021
3 Years ago
igeonlothe questions
Wed, May 31, 23, 02:34, 1 Year ago
Sat, Mar 12, 22, 17:13, 2 Years ago
Tue, Aug 31, 21, 09:46, 3 Years ago
;