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

Unable to associate time pattern with minutes. #248

Open
swateek opened this issue Sep 26, 2018 · 5 comments
Open

Unable to associate time pattern with minutes. #248

swateek opened this issue Sep 26, 2018 · 5 comments

Comments

@swateek
Copy link

swateek commented Sep 26, 2018

I want a job to run every 5th minute, like 10:00..10:05..10:10

When I tried the below code, it throws up an assertion error.

schedule.every().minute.at('00:05').do(job)

Currently as a work around, am running it every minute and checking in my code if its the 5th minute of hour. Is there a nicer way to do it via schedule?

@swateek swateek changed the title Unable to associate patterns with minutes. Unable to associate time pattern with minutes. Sep 26, 2018
@Yonodactyl
Copy link

Yonodactyl commented Oct 2, 2018

Hey swateek, I hope I can provide some insight here.
From my understanding, you want to run the job at hand every 5 minutes so the correct formatting for this would look like:

schedule.every(5).minutes.do(job)

The at definition allows you to schedule the job every Nth day according to the documentation:

def at(self, time_str):
        
        Schedule the job every day at a specific time.

        Calling this is only valid for jobs scheduled to run
        every N day(s).

@Bastian82
Copy link

Assertion says:

assert self.unit in ('days', 'hours') or self.start_day

I tested it and it works for hours aswell:
schedule.every(1).hours.at(00:33).do(job)

@swateek
Copy link
Author

swateek commented Oct 3, 2018

@Yonodactyl when we say every 5 minutes, let's say the process starts at 10:07, the next run would be at 10:12.. right?

What I want is irrespective of whatever time it starts (10:07 in this case), the job should run at 10:10, 10:15 and so on..

@swateek
Copy link
Author

swateek commented Oct 3, 2018

@Bastian82 that piece of code would run the job once every hour. I do have a job that works that way.. with the "at" function.

Can you write a similar code to run every 05th minute of hours (like 10:10, 10:15, 10:20, etc.)?

@Bastian82
Copy link

Bastian82 commented Oct 24, 2018

@Bastian82 that piece of code would run the job once every hour. I do have a job that works that way.. with the "at" function.

Can you write a similar code to run every 05th minute of hours (like 10:10, 10:15, 10:20, etc.)?

Yes, this will run code every 33th minute of every hour:
schedule.every(1).hours.at(00:33).do(job)

As i said it is stated in assertion i mentioned above

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

No branches or pull requests

3 participants