Hello,
is it possible to extend the expression to seconds? I did it now for myself, but it would be nice if this can be switched on and off in the original sourcebase.
Thanks a lot for your work, Mandy
Comment #1
Posted on May 30, 2013 by Massive MonkeyComment deleted
Comment #2
Posted on May 30, 2013 by Massive MonkeyHi, Do you have news about this issue ? Indeed, I work on another open source project : Homidom, and I need to use second in Cron expression. I will continue to use ncrontab which works very well. Thanks for your help, Davidinfo
Comment #3
Posted on May 30, 2013 by Massive OxThere are no new features planned at this time. However, if someone wishes to clone the repo and contribute a robust implementation together with unit tests then I'd be happy to review it and consider another release.
Comment #4
Posted on Oct 30, 2013 by Happy WombatThis project reflects the specification of cronjobs on *nix systems. Which does not have seconds.
See : http://en.wikipedia.org/wiki/Cron
If you need second precision job scheduling, then perhaps you need something else. For example, a background service executing periodically every n seconds.
Comment #5
Posted on Nov 13, 2013 by Massive RabbitComment deleted
Comment #6
Posted on Nov 13, 2013 by Grumpy RabbitI have cloned this repository and have created an implementation that handles both six-part cron expressions and the traditional five-part expressions. It is on the "SixPartCronExpressions" branch of https://code.google.com/r/kfritz-ncrontab/source/browse/?name=SixPartCronExpressions.
azizatif, would you be interested in merging it in?
Comment #7
Posted on Nov 14, 2013 by Massive Ox@kfritz Thanks for patch. Could you switch on code review in your clone through its admin UI?
Comment #8
Posted on Nov 15, 2013 by Grumpy RabbitSwitched on, thanks. I am not very familiar with Google Code.
Comment #9
Posted on Nov 15, 2013 by Massive Ox@kfritz Thanks. Have NCrontabConsole and NCrontabViewer been updated and tested according? I built the solution and ran NCrontabViewer but could not get it to accept a 6-part expression with seconds. If I get the time to dig deeper, I drop in additional notes.
Comment #10
Posted on Nov 15, 2013 by Massive Ox@kfritz Here is what I am seeing:
C:\NCrontab>src\NCrontabConsole\bin\Debug\NCrontabConsole.exe "0 12 1 * mon" 2010-01-01 2011-01-01 01 February 2010 12:00 01 March 2010 12:00 01 November 2010 12:00
C:\NCrontab>src\NCrontabConsole\bin\Debug\NCrontabConsole.exe "30 0 12 1 * mon" 2010-01-01 2011-01-01 '30 0 12 1 * mon' is not a valid crontab expression. It must contain at least 5 components of a schedule (in the sequence of minutes, hours, days, months, days of week).
Comment #11
Posted on Nov 15, 2013 by Grumpy RabbitAh, I was focused on updating the library and didn't take notice of the console and viewer apps. It shouldn't be too hard, though; I'll take a look this afternoon.
Comment #12
Posted on Nov 15, 2013 by Grumpy Rabbit@azizatif, I am unable to reproduce the issues you are seeing with NCrontabConsole. The arguments you demonstrated are working for me. I did, however, push an updated error message. I also updated the Viewer app to show the seconds component when using a six-part expression.
Comment #13
Posted on Nov 15, 2013 by Massive OxOK, the WinForms and Console apps are working (and thanks), but the latter is not displaying the seconds component when a six-part expression is supplied:
C:\NCrontab>src\NCrontabConsole\bin\Debug\NCrontabConsole.exe "30 0 12 1 * mon" 2010-01-01 2011-01-01 01 February 2010 12:00 01 March 2010 12:00 01 November 2010 12:00
Comment #14
Posted on Nov 16, 2013 by Massive RabbitYeah, the console app accepts a format as an argument, so I figured we should just respect whatever format the user supplies.
Comment #15
Posted on Nov 16, 2013 by Massive OxThe only trouble is that the following looks buggy (when it's not):
C:\NCrontab>src\NCrontabConsole\bin\Debug\NCrontabConsole.exe "15,30,45 0 12 1 * mon" 2010-01-01 2011-01-01 01 February 2010 12:00 01 February 2010 12:00 01 February 2010 12:00 01 March 2010 12:00 01 March 2010 12:00 01 March 2010 12:00 01 November 2010 12:00 01 November 2010 12:00 01 November 2010 12:00
Comment #16
Posted on Nov 18, 2013 by Grumpy RabbitShould we just change the default format to "F" and always show seconds, then? Or, do you want the default to change based on what expression comes in? I favor the former as it is probably best to avoid doing more parsing outside the core library.
Comment #17
Posted on Nov 19, 2013 by Massive OxLooks like that the console was designed to take a 4th argument that specifies the format of the output date/time occurrences. Unfortunately, due to a bug, supply the argument would cause an error. I've attached the fix. With it, the following now works:
C:\NCrontab>src\NCrontabConsole\bin\Debug\NCrontabConsole "15,30,45 0 12 1 * mon" 2010-01-01 2011-01-01 F 01 February 2010 12:00:15 01 February 2010 12:00:30 01 February 2010 12:00:45 01 March 2010 12:00:15 01 March 2010 12:00:30 01 March 2010 12:00:45 01 November 2010 12:00:15 01 November 2010 12:00:30 01 November 2010 12:00:45
C:\NCrontab>src\NCrontabConsole\bin\Debug\NCrontabConsole "15,30,45 0 12 1 * mon" 2010-01-01 2011-01-01 "yyyy-MM-dd HH:mm:ss" 2010-02-01 12:00:15 2010-02-01 12:00:30 2010-02-01 12:00:45 2010-03-01 12:00:15 2010-03-01 12:00:30 2010-03-01 12:00:45 2010-11-01 12:00:15 2010-11-01 12:00:30 2010-11-01 12:00:45
I don't think we need to make any further changes with regard to the console app.
- diff.diff 884
Comment #18
Posted on Nov 19, 2013 by Massive OxPatch from comment 17 now applied in changeset 1a62a629d1b93e1ddac2083b33718e0df432fe50
Comment #19
Posted on Nov 19, 2013 by Massive Ox@kfritz I think the last decision that remains with respect to concluding this issue is whether seconds should be optional or mandatory. Beyond the traditional 5 field syntax, there are some implementations supporting 6 or 7 with 6th including seconds and the 7th being the year. In the extended cases, 5 fields are not allowed, making seconds mandatory. Yet another implementation allows fields of higher resolution to be omitted but seconds are always required. It's worth keeping these variations in mind so NCrontab does not introduce an ambiguity in the future. Suppose the year field is added in a future version. At that point, does 6 fields include second or year?
Perhaps there needs to be a classic vs extended mode distinction. In the extended mode, seconds must be required. In the classic mode, it should be illegal to specify anything but 5 fields. A user must choose between classic and extended mode for his/her app.
Comment #20
Posted on Nov 19, 2013 by Grumpy RabbitIf you were to add the year component, I would side for making the seconds a required field. Allowing both the lowest resolution fields and highest resolution fields to be optional would introduce a mess of problems. I defer to your judgement as the project maintainer.
Comment #21
Posted on Nov 20, 2013 by Massive OxI'm not planning to add the year field but don't want to preclude the option in a future version. As a result, the seconds should be required in the non-classic mode so the patch still needs some work.
Comment #22
Posted on Dec 10, 2013 by Massive Ox(No comment was entered for this change.)
Comment #23
Posted on Dec 11, 2013 by Massive OxClosed by change set 7492e5d4f4cc5007f752160585b5ab3a7d302075
Comment #24
Posted on Aug 18, 2014 by Massive Panda@azizatif, do you have plans to release the next version with this change?
Comment #25
Posted on Aug 18, 2014 by Massive Ox@odinserj No promises but but I'll do my to make a release this week.
Comment #26
Posted on Aug 18, 2014 by Massive Ox@odinserj NCrontab 2.0 has been released on NuGet: http://www.nuget.org/packages/ncrontab/2.0.0
Comment #27
Posted on Jan 15, 2015 by Massive RhinoHi I installed Crontab 2.0 and trying to use with Hangfire, but it still throws an error when I use the 6 part cron expression.
Status: Fixed
Labels:
Type-Enhancement
Priority-Medium
Component-Logic
Milestone-Release2.0