Quote:
Originally Posted by CobusA
My entry in crontab file is:
15 */2 1-7,14-21 * 3 /var/lib/command.
My expectation is: My command must execute every first and third Wednesday of the month.
|
Your problem is with your expectation. As written, your job will be executed on the first 7 days of each month, on days 14-21 of each month, and also on any Wednesday. From "man 5 crontab":
Code:
Note: The day of a command’s execution can be specified by two fields —
day of month, and day of week. If both fields are restricted (ie, aren’t
*), the command will be run when either field matches the current time.
For example, "30 4 1,15 * 5" would cause a command to be run at 4:30 am
on the 1st and 15th of each month, plus every Friday.
The standard cron daemon can't do what you want here. Your best solution would be to execute the job every Wednesday and have the job itself check whether the date is in the appropriate range, and exit with a zero return code and without writing to stdout or stderr if not.