Possible Duplicate:
cron : how to schedule to run first Sunday of every month
I want to execute a php script on every first sunday in month at 7 am . I entered the following line in the servers crontab.
0 7 1-7 * 0 user /path/to/script.php
Today I saw that the script did run on wednesday morning. How could that happen? I thought that the last 0
defines sunday?
Thanks for your help in advanced.
From the man page:
Commands are executed by cron(8) when the minute, hour, and month of year fields match the current time, and when at least one of the two day fields (day of month, or day of week) matches the current time (see ``Note'' below).
and later:
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, are not *), 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.
In other words, your script runs on the 1st through the 7th as well as any Sunday.
Fields 3 and 5 don't work together like you're assuming.
You'll need to set field 5 to * and modify your php script to check whether the current day is a Sunday before it continues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With