Python Forum
How to Loop A Script within itself?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Loop A Script within itself?
#1


How would I write a python script that after it gets to the end of itself, waits like one hour, and then restarts itself? How do you make it so it restarts itself on its own without you having to manually open and close the program? I've looked online for a while but haven't found what I'm looking for specifically. I just need a thing to google or pip install. If this is an obvious thing, sorry bout that.

example code input:
print('whateves')
**wait an hour and loop**

***python prints 'whateves', then waits one hour, and prints 'whateves' again, on and on forever and ever as long as my computer is turned on and not asleep.
Reply
#2
you can use python builtin sched.
see: https://pymotw.com/3/sched/
Reply
#3
thank you Tongue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Button to stop while loop from another script Absolutewind 5 818 Sep-25-2023, 11:20 PM
Last Post: deanhystad
  [SOLVED] [Linux] Script in cron stops after first run in loop Winfried 2 894 Nov-16-2022, 07:58 PM
Last Post: Winfried
  how to loop a script? ZYSIA 1 1,966 Jul-22-2021, 06:46 AM
Last Post: Gribouillis
  for loop script over telnet in Python 3.5 is not working abhijithd123 1 2,860 May-10-2020, 03:22 AM
Last Post: bowlofred
  Need help creating complex loop around existing script CephloRhod 5 2,704 Apr-16-2020, 01:23 PM
Last Post: deanhystad
  Loop independent of excecution time of a script Forelli 8 3,678 Feb-02-2020, 10:49 PM
Last Post: snippsat
  Using for loop in Python lists script? NLittle17 4 2,846 Jan-05-2019, 07:08 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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