Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.039 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'exception,': 0.07; 'raises': 0.07; 'coding.': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'monkeys': 0.16; '\xa0print': 0.16; 'cc:addr:python-list': 0.16; 'script.': 0.19; 'seconds': 0.21; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'code.': 0.22; '\xa0if': 0.23; 'thu,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'import': 0.29; 'script': 0.29; 'subject:skip:a 10': 0.29; 'cc:addr:python.org': 0.30; 'day)': 0.30; 'subject:per': 0.30; 'subject:?': 0.31; 'subject:How': 0.36; 'some': 0.37; 'could': 0.37; 'received:google.com': 0.38; 'received:209.85.161': 0.38; 'subject:can': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'run': 0.39; 'manually': 0.39; 'received:209': 0.40; 'where': 0.40; 'below': 0.62; 'ever': 0.65; 'crash': 0.67; 'subject:program': 0.67; 'subject:day': 0.68; 'day': 0.69; 'subject:make': 0.73; 'defensive': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=TJ+mbuHglQ2HTSKiAUEZYurdbxG7m4pnO5dl4GZ2CKk=; b=DEyCascGDyZ6mLZHQn67ykZxpuozZ7W9LO5/d+wD/e5fYoEz7jMWVmz6AIgt8Thu3m vZas9FiWsuz1X//+wgr4jmRFDegVQftnry/EK4GumrfksGGs+qGq7YQz9/HKBkR+kH7z z4+nv0ex08r3o9iCdIc7Bu8L5Bc491D7Nv1Ik= MIME-Version: 1.0 In-Reply-To: <6uidnYUoaNs-vYLTnZ2dnUVZ_sidnZ2d@insightbb.com> References: <54735121-6a94-4dcb-9f6b-e4fca4aad652@u42g2000yqm.googlegroups.com> <6uidnYUoaNs-vYLTnZ2dnUVZ_sidnZ2d@insightbb.com> From: Ian Kelly Date: Thu, 14 Jul 2011 11:13:57 -0600 Subject: Re: How can I make a program automatically run once per day? To: monkeys paw Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310663668 news.xs4all.nl 23916 [2001:888:2000:d::a6]:49883 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9478 On Thu, Jul 14, 2011 at 11:00 AM, monkeys paw wrote: > You could use the below code. time.sleep(# seconds in a day) > where i =3D=3D 30 would run once a day for a month > > import time > i=3D0 > while (1): > =A0 =A0 =A0 =A0print 'hello' > =A0 =A0 =A0 =A0time.sleep(2) =A0 # Change this to number of seconds in a = day > =A0 =A0 =A0 =A0if (i =3D=3D 3): =A0 =A0# make this 30 for a month > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break > =A0 =A0 =A0 =A0i =3D i + 1 If the system ever gets rebooted during that month, then you would need to remember to manually restart the script. Or if the effective part of the script raises an exception, it could crash the whole script without some defensive coding. That's why it's better just to use the system scheduler service.