0

Hi,

I m a newbiee to python, I would like to write one program, and i want that program should run automatically when my system time is 10 am.

Is it possible to do it, if so can any one throw a light to help me
Any kind of help is welcome

thx
sree

2
Contributors
2
Replies
5
Views
9 Years
Discussion Span
Last Post by sreelatha
0

There are a few options depending on your Operating System, and how you want the script to behave. There is no way for Python to just know it's a certain time, unless it is currently running. So, the first option is to have the script running constantly, and just perform the operations you desire at the particular time.

import time

while 1:
	if time.strftime("%H") == "10" and time.strftime("%M") == "00":
		print "Do Whatever you want here"
		time.sleep(60)

I made it sleep for 60 seconds in case whatever operation you want to perform doesn't last for a whole minute, you don't want it repeating. This script will print the string "Do Whatever you want here" every day at 10 am, until it dies.

A better way to implement this is probably to use the OS specific tools, such as scheduled tasks on windows.

Here is a link:
http://support.microsoft.com/kb/308569

0

Hi
Thanks for ur reply

After i posted query here, i tried googling and found the solution with the windows scheduler task.

anyway thx a ton
sree

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.