Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8245813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:18:23+00:00 2026-06-07T22:18:23+00:00

Updated below: I have a script which has a function I made that calculates

  • 0

Updated below:

I have a script which has a function I made that calculates the time to set my script to sleep for based on a few factors, which means the script might not need to run again for a half hour or it could be a few days.

Now, I had thought that time.sleep(seconds) would set the program to sleep and then wake it up and run it again.

time.sleep(3600)
runScriptAgain()

Apparently this doesn’t do what I thought it did. Of course most things never seem to do what I think, the joys of learning!

At any rate once I figured out that the script was never resuming I looked around for other ways to do this. Someone had mentioned os.exec but from my (very limited) knowledge it looks like that is used to run something else from within the script. Then I tried the threading.Timer function but that doesn’t seem to do what I want either. Or I have no idea what I’m doing, which is even more likely. And then I’ve seen people mentioning threads and daemons and things that I have no idea about at all.

I was thinking maybe a for loop but that seems pretty amateurish(pot meet kettle!), and I’m not sure how well that would even work(if at all).

timeToSleep = SleepValue()
count = 0 
while count < timeToSleep:
    count + 1
    time.sleep(1)
runscript()

So is there an easy way to set a script to stop running for a specific amount of time, run again, and then sleep until the next time? I figure there must be a pretty simple way to do this, but I really have no clue. I’m on Windows 7 using Python 3.2.3, and I’ve only been learning python for a few months now so anything complicated is likely to be outside my skill level.

Updated:

def something():
    print('Hello!')

def sleep():
    time.sleep(5)
    runscript()

def runscript():
    something()
    sleep()

runscript()

Ok, that’s how my code is currently setup. I tried it with this simple code and it seems the problem is that it just never wakes up? I’m not really sure what’s going on. I thought it would call the first function, print the item, then sleep for 5 seconds, and repeat ad naseum. Maybe somebody can explain how I should be doing that.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:18:25+00:00Added an answer on June 7, 2026 at 10:18 pm

    You may want to have a look at python’s sched module for this or possibly something like Advanced Python Scheduler. Either way, if you want to run the scheduling from within your script you have to set it up as a long running process or service. Ignacio Vazquez-Abrams’ idea is the most simple – just use your OS’s scheduler (the Window’s task scheduler or cron on Linux) to run it every x minutes. Have your script initially read a config file to determine if it should finish executing or exit. If you need to update or change the next time it should run, you just update the config file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query below that I use to retrieve the records not updated
ORIGINAL (see UPDATED QUESTION below) I am designing a new laboratory database that tests
Based on the 2 databases below: Database_A on Server_1 Database_B on Server_2 I have
I have cloned a git repo which has my emacs config files in. I
I have a Ruby on Rails app that has a scheduled job I execute
I have the following script, which is in an external file called at the
I have a popup confirm box which i am able to show like below.
I have a SQL script which adds a foreign key to a table, as
Update :- My updated script is second one and which is working perfect (
Ok here is my problem. I have a file which outputs an XML based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.