Python Forum
Loop independent of excecution time of a script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop independent of excecution time of a script
#7
schedule work fine for this.
import time, datetime
import subprocess
import schedule

def job():
    print('Hello world')
    print(datetime.datetime.utcnow())
    # External call example
    #subprocess.run(['python', 'run_me.py'])

schedule.every(1).minutes.do(job)
while True:
    schedule.run_pending()
    time.sleep(1)
C:\code\home
λ python 1_min.py
Hello world
2020-02-02 22:09:45.740712
Hello world
2020-02-02 22:10:45.918306
Hello world
2020-02-02 22:11:46.057325
Hello world
2020-02-02 22:12:46.202572
Forelli Wrote:Can someone of the moderators please delete my account and this post too?
We do not delete posts or account.
Just leave and this Thread will go backward and disappear in the crowd Wink
Reply


Messages In This Thread
RE: Loop independent of excecution time of a script - by snippsat - Feb-02-2020, 10:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Button to stop while loop from another script Absolutewind 5 1,165 Sep-25-2023, 11:20 PM
Last Post: deanhystad
  Understanding venv; How do I ensure my python script uses the environment every time? Calab 1 2,587 May-10-2023, 02:13 PM
Last Post: Calab
  [SOLVED] [Linux] Script in cron stops after first run in loop Winfried 2 1,065 Nov-16-2022, 07:58 PM
Last Post: Winfried
  Clock\time calculation script Drone4four 3 1,639 Jan-21-2022, 03:44 PM
Last Post: ibreeden
  Real-Time output of server script on a client script. throwaway34 2 2,209 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  how to loop a script? ZYSIA 1 2,131 Jul-22-2021, 06:46 AM
Last Post: Gribouillis
  How to measure execution time of a multithread loop spacedog 2 3,077 Apr-24-2021, 07:52 AM
Last Post: spacedog
  PyCharm Script Execution Time? muzikman 3 8,770 Dec-14-2020, 11:22 PM
Last Post: muzikman
  Updating a matrix in a time interval inside a for loop vp1989 4 3,062 May-17-2020, 07:15 PM
Last Post: vp1989
  for loop script over telnet in Python 3.5 is not working abhijithd123 1 3,009 May-10-2020, 03:22 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020