Define the execution period of an application

Asked

Viewed 661 times

0

I developed a Python application that registers in the database accessing an email and reading each of the records, generating an Index per record.

I need this application to run on the server daily, from 7:00 to 15:00, how do I program the server to run this application in this specific period?

Thanks in advance.

  • 4

    Have you heard of scheduled Windows tasks?

1 answer

2


welcome!

You can use the task scheduling library for python call schedule (documentation here). With it you can schedule the tasks to be performed, as well as organize the duration and sequence. You can schedule tasks by specific times, days of the week, month, year, etc. You can also set different intervals and use other triggers to trigger the task.

The advantage of using the python rather than solutions such as Cron and the Windows task scheduler, for example, is not having to rewrite the script. There are also cases where the OS does not support the resource. There is also the advantage of, as I have already said, scheduling tasks that are NOT ONLY running time. You’re also more comfortable with the questions of timezones and interactions with language resources.

Anyway, this is it. (Thank you who commented on the post and asked me to improve the response).

Good luck and good studies!

  • 1

    However, in this case, you will need the script to run 24 hours to manage the tasks. Is it feasible to keep the script running from 15:00 to 07:00 unnecessarily?

  • 1

    Anderson is right, for better efficiency it would be better for an operating system service to control the execution of the script, such as Task Scheduler or Cron

  • Well, that’s not how it proposes to be the python Schedule. How it’s going to do that behind really doesn’t matter. Even with the scheduler, some routine needs to check whether or not the script should be fired. Between using a language feature and something from the operating system, I get the language feature.

  • It is worth saying that the solutions of the operating system only serve for that platform. Any migration the script should be rewritten or even OS that does not have the resource. Also, the way to fire the script is via time in OS solutions, but using Schedule you have other ways to do this (different intervals, days of the week, other conditions).

  • 1

    @Igorcavalcanti Perhaps it would be interesting to expose all this in the answer to better substantiate it.

  • Okay, I already did. I realized that my comments are poorly written due to the speed I did, without thinking too much, just saying what I already knew. Thank you, Anderson and Fernando!

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.