Using the schedule Library for Python
Why schedule
It’s simple for:
- “run every hour”
- “run at 09:00 daily”
Example
schedule_example.py
import schedule
import time
def job():
print("running")
schedule.every(10).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)schedule_example.py
import schedule
import time
def job():
print("running")
schedule.every(10).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)Notes
- this keeps a process running
- for server deployment, cron/systemd is usually better
🧪 Try It Yourself
Exercise 1 – List Files with os.listdir
Exercise 2 – Join Paths with os.path.join
Exercise 3 – Write and Read a File
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
