LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-31-2020, 04:41 AM   #1
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,059
Blog Entries: 3

Rep: Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521Reputation: 2521
Python3 event scheduling, with catchup


Which python3 module is most appropriate for scheduling a variable to be True during a certain time interval and False the rest of the time?

Additionally, I am also looking for capabilities to come up with the right value even if the program is started after one of the changeovers.

For example, I could use cron to set True at 13:00 UTC and False at 14:30 UTC but with cron if I start the program at 13:01 UTC, nothing would happen to set True until the next day at 13:00 UTC. I need it to figure out that if the program is fired up during the designated time interval, it should set the appropriate True or False value.

Perhaps there is some well documented solution, since it seems like it might be a common problem.
 
Old 08-31-2020, 06:27 AM   #2
boughtonp
Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 570

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366

There's a datetime module that includes dateless-time objects and timezones.

So use that to define the three times you need, then you should be able to use:

Code:
Variable = ( StartTime <= NowTime < EndTime )
Variable will be true when now is between the two values and false otherwise.

 
1 members found this post helpful.
  


Reply

Tags
python3, scheduling


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
python3 -V returns Python 2.7.12, can't get python3 to work. gene_ Ubuntu 15 03-18-2019 10:39 AM
[SOLVED] making python3.6.4 default python3 Astral Axiom Linux - Newbie 17 04-14-2018 10:55 AM
[SOLVED] how to start python3.6 interpreter just by typing python in terminal not python3.6 bmohanraj91 Linux - Newbie 4 05-10-2017 07:51 AM
After upgrade python3.4 to python3.5.1 , not able to install packages "request" though pip3 YOGESHAS87 Linux - Software 1 08-03-2016 10:38 PM
MicroSoft playing catchup on the back foot TigerOC General 5 06-09-2005 01:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration