Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I'm searching for a library in Python that will give cron like usefulness. 

I'd very much prefer to have a pure Python arrangement, as opposed to depending on instruments installed on the container; this way I run on machines with no cron. 

For those new to cron: you can plan undertakings dependent on articulation like: 

0 2 * * 7 /usr/bin/run-backup # run the backups at 0200 on Every Sunday

 0 9-17/2 * * 1-5 /usr/bin/purge-temps # run the purge temps command, every 2 hours between 9am and 5pm on Mondays to Fridays.

The cron time expression grammar is less significant, however, I might want to have something with such adaptability. 

On the off chance that there isn't something that does this for me out-the-case, any proposals for the structure squares to make something like this would be appreciatively gotten. 

Edit:-  I'm not keen on dispatching measures, just "positions" likewise written in Python - python capacities. By need, I think this would be an alternate string, however not in an alternate cycle. 

To this end, I'm searching for the expressivity of the cron time articulation, yet in Python. 

Cron has been around for quite a long time, yet I'm attempting to be as versatile as could be expected under the circumstances. I can't depend on its quality.

1 Answer

0 votes
by (26.4k points)

Look at the following code:

import schedule

import time

def job():

    print("I'm working...")

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

schedule.every().hour.do(job)

schedule.every().day.at("10:30").do(job)

while 1:

    schedule.run_pending()

    time.sleep(1)

Are you interested to learn the concepts of python? Join the python training course fast!

Browse Categories

...