Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for seconds #24

Closed
danvk opened this issue Apr 20, 2017 · 7 comments
Closed

Add support for seconds #24

danvk opened this issue Apr 20, 2017 · 7 comments

Comments

@danvk
Copy link

danvk commented Apr 20, 2017

I'd like to schedule a task to run every 30 seconds. Is this possible with parse-crontab? Would you be interested in a PR to add support for it?

@josiahcarlson
Copy link
Owner

The syntax that parse-crontab uses is that of cron. Cron as a syntax does not do seconds.

In what context are you using this module? If you're using it with rpqueue, you can just use the periodic_task decorator, specifically @periodic_task(30).

If you are using this module by itself as a scheduler... give me more context and I might be able to lead you to a solution with/without parse-crontab.

@lifeofpython
Copy link

is it possible you extend the lib to support QuartZ Cron for second ? for example 0 0 1 ? * L

@josiahcarlson
Copy link
Owner

I'm not going to change existing syntax on thousands of users to add support for something that people won't give me a use-case for. What are you all using this for where you need cron and not something that explicitly runs in seconds as an explicitly native thing? Why is something else not better?

@kdar
Copy link

kdar commented Oct 6, 2017

A change in syntax doesn't have to have an impact on any preexisting users. See here:
https://github.com/gorhill/cronexpr

I'm using the above library in my program to schedule quite a few jobs. Some run every 45m, some every second. It's nice to be able to use the same cron expression syntax to do both.

@josiahcarlson
Copy link
Owner

Just pushed version 0.22.0 and tagged it. It supports seconds in the same way as cronexpr.

Basically, if you have a 5-entry cron, it will append a '*' as the year and prepend '0' as the seconds entry. If you have a 6-entry cron, it will prepend '0' as the seconds entry. If you have a 7-entry cron, it will assume the first entry is seconds, last is year, and will operate as expected.

Let me know if you have any problems/questions. Thank you for the feature request and reference to something that wouldn't break compatibility with existing expressions.

@hsupu
Copy link

hsupu commented Nov 7, 2017

Thanks a lot you added it now.
I'm making a second-level scheduler. I feel confused when I get True every time if I invoke crontab.test() within one minute, which I've fixed. So happy to find that seconds is supported now.
Another question: Could you publish it to pypi repo? the current version is 0.21.3. Thank you!

@josiahcarlson
Copy link
Owner

Sorry! Pypi changed their upload format, and broke my scripts for upload. Just switched and uploaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants