Comments (8)
This site reports the cron expression as invalid: http://www.cronmaker.com/
I wonder if the test site you're using is working correctly.
from cron-expression.
well, im trying to do a cron: At 14:13 on the 3rd during every February but only if the event takes place on Wednesdays.
that seems the right cron..
if i replace the last 3
with *
then there is no exception, but i need it every Wednesdays
if i use that website, i get 0 13 14 ? 1/3 WED#3 *
but the script gives Invalid CRON field value ? as position 3
from cron-expression.
That's also an invalid CRON for this library for two reason: it appears to have a 'seconds' field and it uses ? instead of *
Your original expressions should be valid, but it won't match what you want (as indicated by the CRON tester output). I'm pretty sure you'd have to use 13 14 2 3 3#1 *
to match only the first Wednesday, however I can't seem to find a cron tester online that supports (and recognizes) the #1
bit.
@mtdowling I'm pretty sure that http://www.cronmaker.com/ is broken. I tried * * * * *
and it said the expression was invalid.
from cron-expression.
@patrioticcow, are you sure you're using the most recent version? It works fine for me on 1.0.4:
$ php -a
Interactive mode enabled
php > require(__DIR__.'/vendor/autoload.php');
php > $c = Cron\CronExpression::factory('13 14 3 2 3');
php > print_r($c->getNextRunDate());
DateTime Object
(
[date] => 2016-02-03 14:13:00.000000
[timezone_type] => 3
[timezone] => UTC
)
from cron-expression.
try tunning
foreach ($cron->getMultipleRunDates(5, 'now') as $date) {
if($date) var_dump($date);
}
from cron-expression.
That threw the exception you reported. If you change it to get each run date individually (instead of all 5 at once), then you can see that there are no more occurrences beyond 2027 that are within the testable range. That limit is imposed by the library to prevent cron schedules that will never be due causing an infinite loop.
That said, you can get around the limit with something like the following:
$dates = array();
for ($i = 0; $i <= 5; $i++) {
$date = $i === 0 ? null : $dates[$i - 1];
$dates[] = $cron->getNextRunDate($date, 0);
}
from cron-expression.
it looks like i have to do lots of testing, when creating the cron to begin with, and make sure the this lib supports it.
Thanks
from cron-expression.
The weird dates are because February 3rd only falls on a Wednesday every 5 - 7 years. If you wanted every Wednesday after the third of February, then the cron would be something like 13 14 3-29 2 3
from cron-expression.
Related Issues (20)
- Class \Cron\YearField not found - Referenced in \Cron\FieldFactory HOT 1
- Not support PHP 7.1.9 HOT 4
- Can you release a 1.2.1 tag? HOT 1
- dragonmantank repository: Unclear where to submit issues HOT 1
- Inconsistent behavior with regards to timezones (2.0) HOT 2
- Composer Autoloader - Not Working (>= 1.6.0) HOT 5
- validate cron expression HOT 1
- Mark this as abandoned on packagist HOT 9
- getMultipleRunDates HOT 1
- Wrong every N-month calculate HOT 1
- Incorrect expression HOT 1
- can't read cron expressions for 6 positions HOT 1
- PSA: Tagging of the 1.2.2 branch caused issues with [insert framework or library] HOT 3
- Yii2 yii2mod/yii2-scheduling - InvalidArgumentException: 5 is not a valid position HOT 2
- abandoned package is required HOT 2
- What is this " 5 is not a valid position" HOT 2
- library incorrectly relies on the timezone set in php.ini
- Express week number
- Invalid CRON field value 30 at position 1 HOT 1
- Add static isValid function to CronExpression to allow testing of expressions prior to creation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cron-expression.