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

  • SEARCH
  • Home
  • 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 8399061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:11:59+00:00 2026-06-09T21:11:59+00:00

What I’m trying to do is execute a script at a certain time, and

  • 0

What I’m trying to do is execute a script at a certain time, and for the most part it does work when I run it a short time frame from execution, say around 10 – 15 minutes. So I would run the timer script and 10 – 15 minutes later it executes it’s command.

Here is the code I’m using:

import time
import myscript
from sys import exit

while 1:
        if time.strftime("%H") == "7" and time.strftime("%M") == "15":
                myscript.main()
                exit()

What I want is for the script to execute everyday in the morning. When I get to my computer later in the day, I can see that the script is stuck on this process.

I’ve tried this on two machines, an Ubuntu 12.04 64 bit box and a Windows XP box with cygwin installed and they both show this same issue. When I leave the computers I’m only locking them, not putting them on standby. I’ve tried running the script and locking it, and then short unlocking it, but I can see that that isn’t the issue because the script runs fine.

Also to note, when I to my computer, it seems to be running very laggy and this script seems to be taking an awful lot of CPU usage, in the range of 30 – 50%.

What else am I missing, or is this not the ideal way to go about it?

  • 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-09T21:12:01+00:00Added an answer on June 9, 2026 at 9:12 pm

    Having no sleep in there explains why your system freaks out. It is spinning as fast as your cpu can go.

    If you are just experimenting with a wrapping script that will run a function at a specific time, you can just do this:

    from datetime import datetime
    import time
    
    while True:
        now = datetime.now()
        if now.hour == 7 and now.minute == 15:
            foo()
        time.sleep(10)
    

    But here is a big problem to think about. What happens if foo() takes a long time or hangs from its own operation?

    What might have been happening in your case is that your sleep (being set to 60 seconds) might have really missed that minute window. You would have to sleep for smaller increments to make sure you check the minute multiple times.

    Aside from this, use a cron job. It is meant to do scheduled tasks. cron will exist in the cygwin shell that you mentioned you are using anyways. Refer here for setting up a crontab on windows

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

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:

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.