Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'interpreter': 0.05; '21,': 0.07; 'bash': 0.09; 'present,': 0.09; 'subject:script': 0.09; 'subject:How': 0.10; 'python': 0.11; 'random': 0.14; "'a',": 0.16; 'fine.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'personally,': 0.16; 'picks': 0.16; 'simpson': 0.16; 'subject:run': 0.16; 'threads,': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'value.': 0.19; 'import': 0.22; 'error': 0.23; 'login': 0.25; 'references': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'unix': 0.29; 'start,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'minor': 0.31; 'quite': 0.32; 'there,': 0.34; 'something': 0.35; 'good.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'subject:?': 0.36; 'requiring': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'numbers': 0.61; "you're": 0.61; "you'll": 0.62; 'more': 0.64; '20,': 0.68; 'subject:day': 0.69; '19.': 0.84; 'length;': 0.84; 'lighter': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=h8AYP/J96/GaPVL/XB0oQrWiQhkEYLrBA9wwAIsTApg=; b=quH0utg0MzsFZhMcvPov201LNKkjOj1xV/4qF5PjknvvchCPgZ0BIBeV0Dtoa5Ckfa Ze4WZcs4gyiHzzCZC/S7yvLW171JEZMTzhmw8vMbp0JACc1FFXXRrkTS2cJkixxb2OzX tJia9BZP+8U1lKQCeZlltvwxYm0D5V7XJlwE26V6fHRJFAK81oJxdV3VxrMoQ+uQHlBG +rk2UgOw1Y5Ihqz4k8YFt54b/Fel/Nh9zRBqDfaZTvMuAQ14yo2QPde4ocMJ/hev8mNm VU52OkvwUtqotd0tKCPwzPQYbih2PvpiM1E82+TsC/YhXvfPhRm39zrYn7n3gK2UFCfU aADQ== MIME-Version: 1.0 X-Received: by 10.58.133.81 with SMTP id pa17mr432144veb.37.1369122987962; Tue, 21 May 2013 00:56:27 -0700 (PDT) In-Reply-To: <20130521011220.GA62488@cskk.homeip.net> References: <20130521011220.GA62488@cskk.homeip.net> Date: Tue, 21 May 2013 17:56:27 +1000 Subject: Re: How to run a python script twice randomly in a day? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369122996 news.xs4all.nl 15993 [2001:888:2000:d::a6]:58460 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45649 On Tue, May 21, 2013 at 11:12 AM, Cameron Simpson wrote: > Ok, good. Some minor remarks: > > Personally, I always use: > > #!/bin/sh > > instead of requiring bash. All UNIX systems have sh, bash is only > common. And even when present, it may not be in /bin. /bin/sh is > always there, and unless you're doing something quite unusual, it > works just fine. Also, on many systems, /bin/sh is a much lighter interpreter than bash (eg Debian uses dash). It's more efficient to use that when you can, even if you use bash for your login shell. > On 20May2013 15:05, Avnesh Shakya wrote: > | but when I m using like > | > | import random > | a = random.randrange(0, 59) > | */a * * * * bash /home/avin/cronJob/test.sh > | then it's showing error becose of varable 'a', so now how can i take > | variable? You put that into your crontab? I do not think this means what you think it means; cron does not execute arbitrary Python code. > - randrange() is like other python ranges: it does not include the end value. > So your call picks a number from 0..58, not 0..59. > Say randrange(0,60). Think "start, length". Nitpick: It's not start, length; it's start, stop-before. If the start is 10 and the second argument is 20, you'll get numbers from 10 to 19. But your conclusion is still accurate :) ChrisA (two Princess Bride references in as many threads, doing well!)