{"action":"created","issue":{"url":"https://api.github.com/repos/flux-framework/flux-core/issues/686","repository_url":"https://api.github.com/repos/flux-framework/flux-core","labels_url":"https://api.github.com/repos/flux-framework/flux-core/issues/686/labels{/name}","comments_url":"https://api.github.com/repos/flux-framework/flux-core/issues/686/comments","events_url":"https://api.github.com/repos/flux-framework/flux-core/issues/686/events","html_url":"https://github.com/flux-framework/flux-core/pull/686","id":158419349,"number":686,"title":"cron-o-date: cron expression support for flux-cron ","user":{"login":"grondo","id":741970,"avatar_url":"https://avatars.githubusercontent.com/u/741970?v=3","gravatar_id":"","url":"https://api.github.com/users/grondo","html_url":"https://github.com/grondo","followers_url":"https://api.github.com/users/grondo/followers","following_url":"https://api.github.com/users/grondo/following{/other_user}","gists_url":"https://api.github.com/users/grondo/gists{/gist_id}","starred_url":"https://api.github.com/users/grondo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grondo/subscriptions","organizations_url":"https://api.github.com/users/grondo/orgs","repos_url":"https://api.github.com/users/grondo/repos","events_url":"https://api.github.com/users/grondo/events{/privacy}","received_events_url":"https://api.github.com/users/grondo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/flux-framework/flux-core/labels/review","name":"review","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-03T17:49:52Z","updated_at":"2016-06-03T20:33:11Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/flux-framework/flux-core/pulls/686","html_url":"https://github.com/flux-framework/flux-core/pull/686","diff_url":"https://github.com/flux-framework/flux-core/pull/686.diff","patch_url":"https://github.com/flux-framework/flux-core/pull/686.patch"},"body":"This isn't quite ready yet, but I'm throwing it up here now because it may need more than usual review.\r\n\r\nThe main purpose of this work was to support cron-like date&time matching for flux-cron. Along the way a lot of other \"improvements\"(?)(remains to be seen) were developed to support the main goal of calculating the amount of time until the next scheduled wakeup for a datetime matching interface such as that cron expressions provide.\r\n\r\nFurthermore, to ensure wakeup on the scheduled datetime, the [`ev_periodic`](http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#code_ev_periodic_code_to_cron_or_not) watcher is now exposed via a `flux_periodic_watcher`.\r\n\r\nThe kind of \"date and time cron expression matching\" interface is abstracted here into a small module called `cronodate`, which is simply a wrapper around an array of `nodeset_t`, one for each of the time units of interest: second, minute, hour, day-of-month, month, and day-of-week. The nodeset for each time unit can be populated with a `cronodate_set ()` using typical nodeset range expressions, or special \"cron\" expressions like `\"*\"`, `\"*/2\"`, etc. and for weekday and month entries, names of the days and months are accepted (like normal vixie-cron). `cronodate` then offers a `cronodate_next()` function to return the date and time of the next scheduled wakeup based on the set of times registered with the `cronodate` object.\r\n\r\nThe `cronodate` interface is then used in a new `datetime` cron entry type, and as a demonstration, a `flux-cron tab` subcommand has been added which can process crontab lines and register flux-cron jobs based on them.\r\n\r\ne.g.\r\n```\r\n$ echo \"25 17 * * * hostname -s # comments\" | flux cron tab                                                                      \r\ntab: cron-4 created: scheduled in 86074.583s at Sat Jun  4 17:25:00 2016\r\n$ echo \"25 17 * * Mon hostname -s # comments\" | flux cron tab                                                 \r\ntab: cron-5 created: scheduled in 258247.385s at Mon Jun  6 17:25:00 2016d\r\n```\r\n\r\nThe `cronodate` code was placed into libutil, though I'm still not convinced that is the right choice. I'm not sure I can think of any other use cases for it, so perhaps it should go into `modules/cron` directly.\r\n\r\nI also added a date parsing  based on `git/date.c` called [`approxidate`](https://github.com/thatguystone/approxidate). Currently it is only used for the `cronodate` tests. However, I was thinking of binding a Lua module to it and using that for a `flux cron at` interface that runs a job once at a specific time.\r\n\r\nFor `cronodate` I also needed to add one call to the `nodeset` interface. I required a way to get the next rank from a nodeset given a current rank (which may or may not be set in the nodeset), and added `nodeset_next_rank (n, r)` for this purpose.\r\n\r\n\r\nStill TODO (at the very least) :\r\n - [ ] man page for `flux cron tab`\r\n - [ ] add `flux cron at`\r\n - [ ] tests for `flux_periodic_watcher`, may need help from [faketime](https://github.com/wolfcw/libfaketime)\r\n - [ ] tests for `flux cron tab`"},"comment":{"url":"https://api.github.com/repos/flux-framework/flux-core/issues/comments/223687349","html_url":"https://github.com/flux-framework/flux-core/pull/686#issuecomment-223687349","issue_url":"https://api.github.com/repos/flux-framework/flux-core/issues/686","id":223687349,"user":{"login":"garlick","id":169947,"avatar_url":"https://avatars.githubusercontent.com/u/169947?v=3","gravatar_id":"","url":"https://api.github.com/users/garlick","html_url":"https://github.com/garlick","followers_url":"https://api.github.com/users/garlick/followers","following_url":"https://api.github.com/users/garlick/following{/other_user}","gists_url":"https://api.github.com/users/garlick/gists{/gist_id}","starred_url":"https://api.github.com/users/garlick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garlick/subscriptions","organizations_url":"https://api.github.com/users/garlick/orgs","repos_url":"https://api.github.com/users/garlick/repos","events_url":"https://api.github.com/users/garlick/events{/privacy}","received_events_url":"https://api.github.com/users/garlick/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T20:33:11Z","updated_at":"2016-06-03T20:33:11Z","body":"Should top of approxidate.c point to git's license?\r\n\r\nhttps://github.com/git/git/blob/master/COPYING\r\n\r\nI don't see a problem dropping that in libutil"}}
{"actor":{"display_login":"garlick"}}