0

can i run my script in an range of hours? For example: I would like to execute my script every day from 6am to 12 pm. At 12:01 pm i would like to kill the process

Thanks

PS: My script is hosted on heroku

Frank
  • 1

1 Answers1

0

TLDR ; use cron in linux- make your python script executable then config your cron to run how ever you want.

In windows you can use a scheduled task.

Abit of explanation about cron- It's basically a time-based job scheduler in Unix-like computer operating systems.

Follow the link below for full explanation on how to run python scripts with crons.

https://medium.com/@gavinwiener/how-to-schedule-a-python-script-cron-job-dea6cbf69f4e

Alternatively if the heroku is running all the time you can use BackgroundScheduler() from APScheduler

reference -Scheduling a function to run every hour on Flask

Yoel Nisanov
  • 984
  • 7
  • 16