Run Cronjob in python
In this article I am going to explain, how can run script on scheduled time. be careful, this script is not proper for run on kubernetis and server side program.
bash
sudo pip install schedulepython
import schedule
import timepython
def job():
now = datetime.datetime.now()
print("The current time is:", now)schedule.every(10).minutes.do(job)while 1:
schedule.run_pending()
time.sleep(1)Python job scheduling for humans. Run Python functions (or any other callable) periodically using a friendly syntax.
- A simple to use API for scheduling jobs, made for humans.
- In-process scheduler for periodic jobs. No extra processes needed!
- Very lightweight and no external dependencies.
- Excellent test coverage.
- Tested on Python 3.7, 3.8, 3.9, 3.10 and 3.11
